我正在开发一个 chrome 扩展,它依赖于执行一个内容脚本来生成一些内容的文本文件,当将扩展加载到 Chrome 浏览器解压时,我发现 GPUCache 文件夹位于下面的路径, 随着空文件呈指数增长。
<块引用>C:\Users<您的用户名>\AppData\Local\Google\Chrome\User 数据\GrShaderCache\GPUCache
此外,只要扩展存在就会发生其他问题,我在下面列出了我遇到的问题
扩展代码
manifest.json
{
"name": "My Extension",
"version": "1.0",
"manifest_version": 3,
"action": {
"default_title": "Click to view a popup",
"default_popup": "index.html"
},
"permissions": [
"activeTab",
"scripting",
"tabs"
]
}
index.html
<!DOCTYPE html>
<html>
<head>
<title>My Extension</title>
<link rel="stylesheet" href="dist/bootstrap.min.css" type="text/css" />
<style>
body {
min-width: 300px;
}
</style>
</head>
<body>
<div class="card">
<h5 class="card-header">My Extension <small>v1.0.0</small></h5>
<div class="card-body text-center">
<p class="card-text">Click "Start".</p>
<input id="start" type="button" class="btn btn-primary" value="Start" />
</div>
</div>
<script src="index.js"></script>
</body>
</html>
index.js
document.getElementById("start").addEventListener("click", start);
function start() {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var tab = tabs[0];
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ['page.js'],
});
})
}
page.js
// this function is a proof of concept of what i intend to do
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
download("hello.txt", "This is the content of my file :)");
我的 Chrome 版本:92.0.4515.107
知道为什么会这样吗?