Skip to content

Commit

Permalink
bugfix: userscript, chrome, is_addon() didn't work
Browse files Browse the repository at this point in the history
At least Tampermonkey seemingly exposes some `chrome` API to userscripts
run on Chrome. Because of this, the userscript/addon detection/
distinction did not work. This is fixed by checking whether the `chrome`
API has a `chrome.runtime` field #1.
  • Loading branch information
JonDerThan committed Feb 1, 2024
1 parent 564a701 commit 97c428b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bookbuyer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let pendingChecks = [-1, -1, -1, -1]

// Check whether the script is currently executed as an add-on.
function isAddon() {
return typeof chrome !== "undefined"
return typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined"
}

// Run as an add-on.
Expand Down

0 comments on commit 97c428b

Please sign in to comment.