Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

run the selector js on document_end instead of document_idle #2538

Merged
merged 1 commit into from
Mar 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions addon/webextension/background/selectorLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ window.selectorLoader = (function () {

exports.unloadIfLoaded = function (tabId) {
return browser.tabs.executeScript(tabId, {
code: "window.selectorLoader && window.selectorLoader.unloadModules()"
code: "window.selectorLoader && window.selectorLoader.unloadModules()",
runAt: "document_start"
}).then(result => {
return result && result.toString() === "true";
});
Expand All @@ -32,7 +33,10 @@ window.selectorLoader = (function () {
let lastPromise = Promise.resolve(null);
scripts.forEach((file) => {
lastPromise = lastPromise.then(() => {
return browser.tabs.executeScript(tabId, {file})
return browser.tabs.executeScript(tabId, {
file,
runAt: "document_end"
})
.catch((error) => {
console.error("error in script:", file, error);
error.scriptName = file;
Expand Down