aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-11 15:17:25 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-11 15:17:25 -0400
commit3c48290cd83744983df2e708b892a8415bcf750f (patch)
treec28e6f493a087ebcff9c9d4d65c25f896f30c1c0 /ext/mixed/js
parent82f83970001682018f1f5b595ffdcd13123fed91 (diff)
Add isExtensionUrl utility function to yomichan object
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/core.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 2d11c11a..6a3298fc 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -316,6 +316,15 @@ const yomichan = (() => {
this.trigger('orphaned', {error});
}
+ isExtensionUrl(url) {
+ try {
+ const urlBase = chrome.runtime.getURL('/');
+ return url.substring(0, urlBase.length) === urlBase;
+ } catch (e) {
+ return false;
+ }
+ }
+
getTemporaryListenerResult(eventHandler, userCallback, timeout=null) {
if (!(
typeof eventHandler.addListener === 'function' &&