К счастью, scripting.registerContentscripts () дает вам Вариант определения списка веб -страниц, которые следует рассматривать как белый список, используя параметр excludeMatches в директиве, для представления массива страниц, где сценарий не должен быть введен.
< P> Здесь просто образец того, что я имею в виду: < /p>
Код: Выделить всё
const matches = ['*://*/*'];
const excludeMatches = ['*://*.example.com/*'];
< /code>
const directive = {
id: 'injected-jstest',
js: ['injectedscript.js'],
matches: matches,
excludeMatches: excludeMatches,
persistAcrossSessions: false,
runAt: 'document_start'
};
< /code>
await chrome.scripting.registerContentScripts([directive])
.catch(reason => { console.log("[SW] >>> inject script error:",reason); });
< /code>
Of course, the whitelist is not static, but varies over time according to the needs of the moment.
Everything works perfectly in Chromium browsers (Chrome, Edge, ...) and Firefox, but fails miserably in Safari. In fact, Safari seems to [b]completely ignore[/b] the excludeMatchesПодробнее здесь: https://stackoverflow.com/questions/794 ... tally-igno
Мобильная версия