Skip to content

Instantly share code, notes, and snippets.

@satyr
Created May 29, 2010 19:00
Show Gist options
  • Save satyr/418451 to your computer and use it in GitHub Desktop.
Save satyr/418451 to your computer and use it in GitHub Desktop.
Halt Alert
// ==UserScript==
// @name Halt Alert
// @description Provides ways to escape loop-y modal dialogs.
// @include chrome://global/content/commonDialog.xul
// @compat 3.5+
// @author satyr
// @license X
// ==/UserScript==
setTimeout(function HA_setup(){
var box = document.documentElement.appendChild(lmn('hbox'));
self.ha_stop = box.appendChild(lmn(
'checkbox', {label:'Stop script', accesskey:'S', checked:false}));
self.ha_wipe = box.appendChild(lmn(
'checkbox', {label:'Wipe window', accesskey:'W', checked:false}));
sizeToContent();
function lmn(name, atrs){
var lm = document.createElement(name);
for(let key in atrs) lm.setAttribute(key, atrs[key]);
return lm;
}
});
addEventListener('unload', function HA_halt(){ try {
if(ha_stop.checked)
opener.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell)
.allowJavascript = false;
if(ha_wipe.checked) opener.location = 'about:blank';
} catch(e){ Cu.reportError(e) }}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment