Fix wrapped negative look ahead & extra grouped items
See https://jsbin.com/miyujifaco/edit?js,console
This commit is contained in:
parent
d278d26553
commit
3f36ecd8e5
|
@ -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] : '';
|
||||
|
|
Loading…
Reference in New Issue
Block a user