diff --git a/manage/manage.js b/manage/manage.js index 81ad0868..92018467 100644 --- a/manage/manage.js +++ b/manage/manage.js @@ -294,12 +294,13 @@ function recreateStyleTargets({styles, iconsOnly = false} = {}) { }); } - function getFaviconImgSrc() { const targets = $$('.target', installed); - const regexpRemoveNegativeLookAhead = /(\?!([^)]+\)))/g; - const regexpMatchRegExp = /\w+[\\.(]+(com|org|co|net|im|io)\b/g; - const regexpReplaceExtraCharacters = /[\\(]/g; + const regexpRemoveNegativeLookAhead = /(\?!([^)]+\))|\(\?![\w(]+[^)]+[\w|)]+)/g; + // replace extra characters & all but the first group entry "(abc|def|ghi)xyz" => abcxyz + const regexpReplaceExtraCharacters = /[\\(]|((\|\w+)+\))/g; + const domainExt = 'com,org,co,net,im,io,edu,gov,biz,info,de,cn,uk,nl,eu,ru'.split(','); + const regexpMatchRegExp = new RegExp(`[\\w-]+[\\.(]+(${domainExt.join('|')})\\b`, 'g'); const regexpMatchDomain = /^.*?:\/\/([^/]+)/; for (const target of targets) { const type = target.dataset.type; @@ -310,8 +311,11 @@ function getFaviconImgSrc() { } else if (targetValue.includes('chrome-extension:') || targetValue.includes('moz-extension:')) { favicon = OWN_ICON; } else if (type === 'regexps') { - favicon = targetValue.replace(regexpRemoveNegativeLookAhead, '').match(regexpMatchRegExp); - favicon = favicon ? GET_FAVICON_URL + favicon.shift().replace(regexpReplaceExtraCharacters, '') : ''; + favicon = targetValue + .replace(regexpRemoveNegativeLookAhead, '') + .replace(regexpReplaceExtraCharacters, '') + .match(regexpMatchRegExp); + favicon = favicon ? GET_FAVICON_URL + favicon.shift() : ''; } else { favicon = targetValue.includes('://') && targetValue.match(regexpMatchDomain); favicon = favicon ? GET_FAVICON_URL + favicon[1] : '';