Skip to content

Instantly share code, notes, and snippets.

@tim-we
Created December 21, 2018 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-we/592e271c9517af6b9bcaadd811056d26 to your computer and use it in GitHub Desktop.
Save tim-we/592e271c9517af6b9bcaadd811056d26 to your computer and use it in GitHub Desktop.
Temporary fix for bug 1513656
/* Fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1513656
* Include this script in the sidebar.
*/
(function(){
let _alert = window.alert,
_confirm = window.confirm,
_prompt = window.prompt;
let bg = null;
function addBackgroundElement() {
bg = document.createElement("div");
bg.style.position = "fixed";
bg.style.top = "0px";
bg.style.bottom = "0px";
bg.style.left = "0px";
bg.style.right = "0px";
bg.style.backgroundColor = "white";
bg.style.zIndex = "9999";
document.body.appendChild(bg);
}
function removeBackgroundElement() {
document.body.removeChild(bg);
}
// apply fix
window.alert = text => {
addBackgroundElement();
_alert(text);
removeBackgroundElement();
};
window.confirm = text => {
addBackgroundElement();
let res = _confirm(text);
removeBackgroundElement();
return res;
};
window.prompt = (text, _default) => {
addBackgroundElement();
let res = _prompt(text, _default);
removeBackgroundElement();
return res;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment