Skip to content

Commit 931c4c1

Browse files
committed
Merge branch 'exists-calls-too-frequent' into development
2 parents 3e5754c + 772a891 commit 931c4c1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

wallabagger/js/background.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ function onTabCreatedListener (tab) {
123123
}
124124

125125
function onTabUpdatedListener (tabId, changeInfo, tab) {
126-
if (changeInfo.status === 'loading' && tab.active) {
127-
saveExistFlag(tab.url, existStates.notexists);
128-
requestExists(tab.url);
126+
if ((changeInfo.status === 'loading') && tab.active) {
127+
checkExist(tab.url);
129128
}
130129
}
131130

@@ -457,8 +456,9 @@ function savePageToWallabag (url, resetIcon) {
457456

458457
const GotoWallabag = (part) => api.checkParams() && browser.tabs.create({ url: `${api.data.Url}/${part}/list` });
459458

460-
const checkExist = (url) => {
461-
if (isServicePage(url)) { return; }
459+
const checkExist = (dirtyUrl) => {
460+
if (isServicePage(dirtyUrl)) { return; }
461+
const url = dirtyUrl.split('#')[0];
462462
if (existCache.check(url)) {
463463
const existsFlag = existCache.get(url);
464464
if (existsFlag === existStates.exists) {
@@ -491,7 +491,7 @@ const saveExistFlag = (url, exists) => {
491491
existCache.set(url, exists);
492492
};
493493

494-
const isServicePage = (url) => RegExp('((chrome|about|browser):(.*)|' + api.data.Url + ')', 'g').test(url);
494+
const isServicePage = (url) => !/^https?:\/\/.+/.test(url) || RegExp('^' + api.data.Url).test(url);
495495

496496
const addToAllTags = (tags) => {
497497
if (tags.length === 0) { return; }

0 commit comments

Comments
 (0)