code cosmetics: RX_SUPPORTED_URLS -> URLS.supported

This commit is contained in:
tophf 2017-04-17 22:43:59 +03:00
parent 021f50015b
commit 3b3ed6543e
4 changed files with 12 additions and 8 deletions

View File

@ -11,7 +11,6 @@ env:
globals:
# messaging.js
KEEP_CHANNEL_OPEN: false
RX_SUPPORTED_URLS: false
FIREFOX: false
OPERA: false
URLS: false

View File

@ -1666,7 +1666,6 @@ function showLintHelp() {
function showRegExpTester(event, section = getSectionForChild(this)) {
const GET_FAVICON_URL = 'https://www.google.com/s2/favicons?domain=';
const OWN_ICON = chrome.runtime.getManifest().icons['16'];
const RX_SUPPORTED_URLS = new RegExp(`^(file|https?|ftps?):|^${URLS.ownOrigin}`);
const cachedRegexps = showRegExpTester.cachedRegexps =
showRegExpTester.cachedRegexps || new Map();
const regexps = [...section.querySelector('.applies-to-list').children]
@ -1696,7 +1695,7 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
});
chrome.tabs.query({}, tabs => {
const supported = tabs.map(tab => tab.url)
.filter(url => RX_SUPPORTED_URLS.test(url));
.filter(url => URLS.supported.test(url));
const unique = [...new Set(supported).values()];
for (const rxData of regexps) {
const {rx, urls} = rxData;

View File

@ -3,25 +3,31 @@
// keep message channel open for sendResponse in chrome.runtime.onMessage listener
const KEEP_CHANNEL_OPEN = true;
const FIREFOX = /Firefox/.test(navigator.userAgent);
const OPERA = /OPR/.test(navigator.userAgent);
const URLS = {
ownOrigin: chrome.runtime.getURL(''),
optionsUI: [
chrome.runtime.getURL('options/index.html'),
'chrome://extensions/?options=' + chrome.runtime.id,
],
configureCommands:
OPERA ? 'opera://settings/configureCommands'
: 'chrome://extensions/configureCommands',
// CWS cannot be scripted in chromium, see ChromeExtensionsClient::IsScriptableURL
// https://cs.chromium.org/chromium/src/chrome/common/extensions/chrome_extensions_client.cc
chromeWebStore: FIREFOX ? 'N/A' : 'https://chrome.google.com/webstore/',
supported: new RegExp(
'^(file|ftps?|http)://|' +
`^https://${FIREFOX ? '' : '(?!chrome\\.google\\.com/webstore)'}|` +
'^' + chrome.runtime.getURL('')),
};
const RX_SUPPORTED_URLS = new RegExp(
'^(file|ftps?|http)://|' +
`^https://${FIREFOX ? '' : '(?!chrome\\.google\\.com/webstore)'}|` +
'^' + URLS.ownOrigin);
let BG = chrome.extension.getBackgroundPage();

View File

@ -5,7 +5,7 @@ let tabURL;
const handleEvent = {};
getActiveTabRealURL().then(url => {
tabURL = RX_SUPPORTED_URLS.test(url) ? url : '';
tabURL = URLS.supported.test(url) ? url : '';
Promise.all([
tabURL && getStylesSafe({matchUrl: tabURL}),
onDOMready().then(() => {