parent
916a3bced3
commit
8960a9f5ce
12
edit/edit.js
12
edit/edit.js
|
@ -1866,6 +1866,8 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
|
||||||
chrome.tabs.onUpdated.removeListener(_);
|
chrome.tabs.onUpdated.removeListener(_);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const getMatchInfo = m => m && {text: m[0], pos: m.index};
|
||||||
|
|
||||||
queryTabs().then(tabs => {
|
queryTabs().then(tabs => {
|
||||||
const supported = tabs.map(tab => tab.url)
|
const supported = tabs.map(tab => tab.url)
|
||||||
.filter(url => URLS.supported(url));
|
.filter(url => URLS.supported(url));
|
||||||
|
@ -1875,7 +1877,7 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
|
||||||
if (rx) {
|
if (rx) {
|
||||||
const urlsNow = new Map();
|
const urlsNow = new Map();
|
||||||
for (const url of unique) {
|
for (const url of unique) {
|
||||||
const match = urls.get(url) || (url.match(rx) || [])[0];
|
const match = urls.get(url) || getMatchInfo(url.match(rx));
|
||||||
if (match) {
|
if (match) {
|
||||||
urlsNow.set(url, match);
|
urlsNow.set(url, match);
|
||||||
}
|
}
|
||||||
|
@ -1909,7 +1911,7 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
|
||||||
? OWN_ICON
|
? OWN_ICON
|
||||||
: GET_FAVICON_URL + new URL(url).hostname;
|
: GET_FAVICON_URL + new URL(url).hostname;
|
||||||
const icon = $element({tag: 'img', src: faviconUrl});
|
const icon = $element({tag: 'img', src: faviconUrl});
|
||||||
if (match.length === url.length) {
|
if (match.text.length === url.length) {
|
||||||
full.push($element({appendChild: [
|
full.push($element({appendChild: [
|
||||||
icon,
|
icon,
|
||||||
url,
|
url,
|
||||||
|
@ -1917,9 +1919,9 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
|
||||||
} else {
|
} else {
|
||||||
partial.push($element({appendChild: [
|
partial.push($element({appendChild: [
|
||||||
icon,
|
icon,
|
||||||
url.substr(0, match.index),
|
url.substr(0, match.pos),
|
||||||
$element({tag: 'mark', textContent: match}),
|
$element({tag: 'mark', textContent: match.text}),
|
||||||
url.substr(match.length),
|
url.substr(match.pos + match.text.length),
|
||||||
]}));
|
]}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user