From 810b2ba15eb9b994c9e26e205ace52dfae0c184e Mon Sep 17 00:00:00 2001 From: papush Date: Sun, 29 Aug 2021 16:53:20 +0200 Subject: fix browser pref syncing and clean up overlay init --- chrome/js/browserOverlay.js | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/chrome/js/browserOverlay.js b/chrome/js/browserOverlay.js index 1d3efab..81d19f2 100644 --- a/chrome/js/browserOverlay.js +++ b/chrome/js/browserOverlay.js @@ -2,33 +2,19 @@ Components.utils.import("chrome://redirector/content/js/redirectorprefs.js"); Components.utils.import("chrome://redirector/content/js/redirector.js"); var RedirectorOverlay = { - strings : null, prefs : null, onLoad : function(event) { - try { - - // initialization code - document.getElementById('contentAreaContextMenu') - .addEventListener("popupshowing", function(e) { RedirectorOverlay.showContextMenu(e); }, false); - - this.strings = document.getElementById("redirector-strings"); - this.prefs = new RedirectorPrefs(); - this.changedPrefs(this.prefs); - this.prefs.addListener(this); - document.addEventListener('keypress', function(event) { - if ((event.charCode == 114) && event.altKey) { //alt+r - RedirectorOverlay.toggleEnabled(); - } - }, true); - } catch(e) { - if (this.strings) { - alert(this.strings.getString("initError") + "\n\n" + e); - } else { - alert(e); + this.strings = document.getElementById("redirector-strings"); + this.prefs = new RedirectorPrefs(); + this.changedPrefs(this.prefs); + this.prefs.addListener(this); + document.addEventListener('keypress', function(event) { + if ((event.charCode == 114) && event.altKey) { //alt+r + RedirectorOverlay.toggleEnabled(); } - } + }, true); }, onUnload : function(event) { @@ -37,8 +23,6 @@ var RedirectorOverlay = { }, changedPrefs : function(prefs) { - var button = document.getElementById('redirector-button'); - document.getElementById('redirector-context').hidden = !prefs.showContextMenu; this.refreshUI(); }, @@ -70,5 +54,6 @@ var RedirectorOverlay = { }); } }; + window.addEventListener("load", function(event) { RedirectorOverlay.onLoad(event); }, false); window.addEventListener("unload", function(event) { RedirectorOverlay.onUnload(event); }, false); -- cgit v1.2.3-70-g09d2