用這個uc腳本也可以:
代碼:
// ==UserScript==
// @name disableAlert.uc.js
// @description 在alert confirm prompt中添加终止脚本的复选框
// @author slimx
// @version 3/10
// ==/UserScript==
var DisableAlert = {
label:"\u505c\u6b62\u6267\u884c\u6b64\u9875\u9762\u4e2d\u7684\u811a\u672c",
content:null,
onLoad: function() {
var appcontent = document.getElementById("appcontent");
if(appcontent) {
appcontent.addEventListener("DOMWillOpenModalDialog", DisableAlert.modalDialogOverride, true);
appcontent.addEventListener("DOMContentLoaded",DisableAlert.modalDialogOverride, true);
}
},
modalDialogOverride: function(e) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService( Components.interfaces.nsIPromptService );
document.getElementById("content").contentWindow.wrappedJSObject.alert = function(text) {
var alertCheckboxChoice = {value: false};
promptService.alertCheck(window, "[JavaScript Application]", text, DisableAlert.label, alertCheckboxChoice);//停止执行此页面中的脚本
if (alertCheckboxChoice.value) {
document.getElementById("content").contentWindow.wrappedJSObject.alert = function(){};
throw new Error();
}
};
document.getElementById("content").contentWindow.wrappedJSObject.confirm = function(text) {
var confirmCheckboxChoice = {value: false};
var confirmChoice = promptService.confirmCheck(window, "[JavaScript Application]", text, DisableAlert.label, confirmCheckboxChoice);
if (confirmCheckboxChoice.value) {
document.getElementById("content").contentWindow.wrappedJSObject.confirm = function(){
};
throw new Error();
}
return confirmChoice;
};
document.getElementById('content').contentWindow.wrappedJSObject.prompt = function(prompt_text, default_input) {
var check = {value: false};
var response = {value: default_input};
var success = promptService.prompt(window, "[Javascript Application]",
prompt_text, response, DisableAlert.label,check);
if (check.value) {
document.getElementById('content').contentWindow.wrappedJSObject.prompt = function(){};
throw new Error();
}
return success?response.value:null;
};
},
addClose:function(){
window.document.getElementById("info.icon").addEventListener("dblclick",function() {
window.opener.content.document.location="about:blank";
}, false);
window.document.getElementById("info.icon").setAttribute("tooltiptext","\u53cc\u51fb\u5173\u95ed\u9875\u9762");//双击关闭页面
},
};
DisableAlert.onLoad();
DisableAlert.addClose();