我的manifest.json文件:
{
"manifest_version": 3,
"name": "File Upload Blocker",
"version": "1.0",
"permissions": [
"activeTab"
],
"content_scripts": [
{
"matches": ["https://example.com/*", "https://another-example.com/*"],
"js": ["background.js"]
}
]
}
我的background.js文件:
document.addEventListener('change', function(event) {
const input = event.target;
if (input.type === 'file') {
const files = input.files;
for (let i = 0; i < files.length; i++) {
const fileName = files[i].name.toLowerCase();
if (fileName.endsWith('.bmp') || fileName.endsWith('.png') || fileName.endsWith('.gif')) {
alert('不允许上传该文件类型:' + files[i].name);
input.value = ''; // 清空文件输入
break;
}
}
}
});
我加入了Chrome浏览器扩展
但在真正上传档案时
只有跳出视窗「不允许上传该文件类型」提醒
但是却无法做到真正的封阻档案上传
甚至有些网站还没有跳出封阻提醒
我该入更改程式码