From 96ac11572706821f0da39e905494929f9871267b Mon Sep 17 00:00:00 2001
From: Dongwon Lee
Date: Fri, 23 Feb 2024 15:09:32 +0900
Subject: [PATCH 1/2] add functions
---
background.js | 4 +++-
content.js | 11 ++++++++++-
options.html | 7 +++++++
options.js | 1 +
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/background.js b/background.js
index 5f89fb8..c2cddd0 100644
--- a/background.js
+++ b/background.js
@@ -68,6 +68,7 @@
showPopup: false,
showPopupOnMouseOver: false,
showTrace: false,
+ showDetailOnIncludeDomains: false,
}
for (var option in optionsValues) {
var value = optionsValues[option]
@@ -169,7 +170,8 @@
popupMaxHeight: await LS.getItem('popupMaxHeight'),
includeDomains: await LS.getItem('includeDomains'),
iconSize: await LS.getItem('iconSize'),
- notificationIconOpacity: await LS.getItem('notificationIconOpacity')
+ notificationIconOpacity: await LS.getItem('notificationIconOpacity'),
+ showDetailOnIncludeDomains: await LS.getItem('showDetailOnIncludeDomains'),
}
}
diff --git a/content.js b/content.js
index 88550cd..8805689 100644
--- a/content.js
+++ b/content.js
@@ -35,7 +35,7 @@ new (function () {
}
function showErrorNotification(popupUrl) {
- if (options.showPopup) {
+ if (options.showPopup || (options.showDetailOnIncludeDomains && options.includeDomains.indexOf(getBaseHostByUrl(window.location.href)) + 1)) {
showPopup(popupUrl)
}
var includeSite = false
@@ -193,4 +193,13 @@ new (function () {
options = response
})()
}
+
+ function getBaseHostByUrl(url) {
+ var localUrlRegexp = /(file:\/\/.*)|(:\/\/[^.:]+([\/?:]|$))/ // file:// | local
+ var rootHostRegexp = /:\/\/(([\w-]+\.\w+)|(\d+\.\d+\.\d+\.\d+)|(\[[\w:]+\]))([\/?:]|$)/ // domain.com | IPv4 | IPv6
+ var subDomainRegexp = /:\/\/[^\/]*\.([\w-]+\.\w+)([\/?:]|$)/ // sub.domain.com
+ return localUrlRegexp.exec(url)
+ ? 'localhost'
+ : (rootHostRegexp.exec(url) || subDomainRegexp.exec(url))[1]
+ }
})()
diff --git a/options.html b/options.html
index dabbf0e..9c87b62 100644
--- a/options.html
+++ b/options.html
@@ -109,6 +109,13 @@ Global options
+