Created
June 27, 2012 21:50
-
-
Save stechz/3007080 to your computer and use it in GitHub Desktop.
Addon SDK code for removing onbeforeclose alerts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function contentScript() { | |
var script = document.createElement('script'); | |
script.setAttribute('type', 'text/javascript'); | |
script.setAttribute('src', 'data:text/javascript,' + escape( | |
'(' + function() { | |
onbeforeunload = null; | |
}.toString() + ')()')); | |
document.body.appendChild(script); | |
} | |
var pagemod = require("page-mod"); | |
pagemod.PageMod({ | |
include: 'https://supyo.hipchat.com/*', | |
contentScriptWhen: 'end', | |
contentScript: '(' + contentScript.toString() + ')();' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may also consider using window.defineProperty() to guarantee that onbeforeunload never gets overwritten.