如何解决通过内容脚本阻止将文件放入 chrome
我试图通过 chrome 扩展中的内容脚本阻止所有放置事件。但是,代码正在执行,因为我可以获得 console.log
输出,但不会阻止文件丢失。
inject.js
文件:
console.log("worked?");
document.addEventListener("ondrop",function(event){
event.preventDefault();
},false)
document.addEventListener("dragstart",function(event){
event.preventDefault();
},true);
document.addEventListener("dragenter",true);
document.addEventListener("dragleave",true);
document.addEventListener("drag",true);
manifest.json
文件:
{
"name": "BlockDrop","version": "0.0.1","manifest_version": 2,"description": "Block dropping of files .","homepage_url": "http://sample.com?explode_chrome","icons": {
"16": "icons/icon16.png","48": "icons/icon48.png","128": "icons/icon128.png"
},"default_locale": "en","background": {
"scripts": [
"src/bg/background.js"
],"persistent": true
},"browser_action": {
"default_icon": "icons/icon19.png","default_title": "browser action demo","default_popup": "src/browser_action/browser_action.html"
},"permissions": [
"clipboardRead","clipboardWrite","cookies","https://*/*","http://*/*"
],"content_scripts": [
{
"matches": [
"https://*/*","http://*/*"
],"js": [
"src/inject/inject.js"
],"run_at" : "document_idle"
}
]
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。