Skip to content

Commit

Permalink
crutch for slowly initialized settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dezaimasu committed Sep 27, 2018
1 parent e6b4a98 commit 41b9bc0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,12 @@ const de_contentscript = {
const de_listeners = {
mouseoverListener: function(event){
if (event.target.tagName === de_button.name || (event.relatedTarget && event.relatedTarget.tagName === de_button.name)) {return;}
de_contentscript.nodeHandler(event.target, event);
try {
de_contentscript.nodeHandler(event.target, event);
} catch (e) {
if (!e.message.includes('de_settings')) {return;} // settings are not initialized yet
setTimeout(() => {de_contentscript.nodeHandler(event.target, event);}, 100);
}
},
keydownListener: function(event){
if (de_hotkeys.isHotkeyPossible(event) && de_hotkeys.isHotkeyExists(de_hotkeys.buildHotkeyId(event))) {
Expand Down Expand Up @@ -572,4 +577,5 @@ function xpath(path, contextNode){
return document.evaluate(path, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

window.addEventListener('mouseover', de_listeners.mouseoverListener); // asap
de_contentscript.init();

0 comments on commit 41b9bc0

Please sign in to comment.