In Chrome 61.0.3161+ NTP can't be styled anymore

This commit is contained in:
tophf 2017-07-22 19:52:07 +03:00
parent b37b2c5246
commit 3b49d83616
11 changed files with 37 additions and 54 deletions

View File

@ -576,10 +576,6 @@
"message": "Разширението не работи на такива страници.",
"description": "Note in the toolbar pop-up when on a URL Stylus can't affect"
},
"stylusUnavailableForURLdetails": {
"message": "Като предпазна мярка, четецът забранява на разширенията да влияят на вградените страници (например chrome://version или about:addons), както и на страниците на други разширения. Достъпът до магазина с добавки също е ограничен.",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"toggleStyle": {
"message": "Превключване на стила",
"description": "Label for the checkbox to enable/disable a style"

View File

@ -568,10 +568,6 @@
"message": "Automatické dokončování během psaní",
"description": "Label for the checkbox in the style editor."
},
"stylusUnavailableForURLdetails": {
"message": "Jako bezpečností opatření, prohlížeč brání rozšířením v ovlivnění vestavěných stránek (např. chrome://version nebo about:addons) a stránek dalších rozšíření. Každý prohlížeč také omezuje přístup do vlastního obchodu s rozšířeními (např. Chrome Web Store nebo AMO).",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "Pouze výběr",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -548,10 +548,6 @@
"message": "Autovervollständigen bei Eingabe",
"description": "Label for the checkbox in the style editor."
},
"stylusUnavailableForURLdetails": {
"message": "Der Browser verbietet als Sicherheitsvorkehrung den Zugriff der Erweiterung auf interne Seiten (wie z.B. chrome://version oder about:addons) sowie andere Erweiterungsseiten. Jeder Browser begrenzt den Zugriff auf eigene Erweiterungs-Galerien (wie z.B. den Chrome Web Store oder addons.mozilla.org).",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "Nur die Auswahl",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -577,7 +577,7 @@
"description": "Note in the toolbar pop-up when on a URL Stylus can't affect"
},
"stylusUnavailableForURLdetails": {
"message": "As a security precaution, the browser prohibits extensions from affecting its built-in pages (like chrome://version or about:addons) as well as other extensions' pages. Each browser also restricts access to its own extensions gallery (like Chrome Web Store or AMO).",
"message": "As a security precaution, the browser prohibits extensions from affecting its built-in pages (like chrome://version, the standard new tab page as of Chrome 61, about:addons, and so on) as well as other extensions' pages. Each browser also restricts access to its own extensions gallery (like Chrome Web Store or AMO).",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"toggleStyle": {

View File

@ -572,10 +572,6 @@
"message": "Autocompletar al escribir",
"description": "Label for the checkbox in the style editor."
},
"stylusUnavailableForURLdetails": {
"message": "Como medida de precaución, el navegador prohíbe que las extensiones afecten a sus páginas internas (como chrome://version o about:addons) además de las páginas internas de otras extensiones. Cada navegador además restringe el acceso a su propia galería de extensiones (como Chrome Web Store o AMO).",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "Sólo selección",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -468,10 +468,6 @@
"message": "削除",
"description": "Label for the context menu item in the editor to delete selected text"
},
"stylusUnavailableForURLdetails": {
"message": "セキュリティ上の予防措置として、ブラウザは拡張機能が他の拡張機能のページと同様に、内蔵のページchrome://versionやabout:addonsなどに影響を及ぼさないようにします。各ブラウザは、独自の拡張機能ギャラリーChromeウェブストアやAMOなどへのアクセスも制限しています。",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "選択した単語のみ",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -572,10 +572,6 @@
"message": "Подсказки при наборе кода",
"description": "Label for the checkbox in the style editor."
},
"stylusUnavailableForURLdetails": {
"message": "В целях обеспечения безопасности браузер запрещает расширениям изменять встроенные страницы (например, chrome://version, about:addons), страницы других расширений и \"магазин\" расширений (Chrome Web Store в chromium-браузерах, AMO в Firefox и т.д.)",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "Выделенный текст",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -572,10 +572,6 @@
"message": "输入时自动完成",
"description": "Label for the checkbox in the style editor."
},
"stylusUnavailableForURLdetails": {
"message": "出于安全原因,浏览器禁止扩展影响内置页面(例如 chrome://version 或 about:addons以及其他扩展的页面。各浏览器同时也限制介入自己的扩展网站如 Chrome 网上应用店、Firefox 附加组件)。",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "选择区域",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -572,10 +572,6 @@
"message": "在輸入時自動完成",
"description": "Label for the checkbox in the style editor."
},
"stylusUnavailableForURLdetails": {
"message": "做為安全措施,瀏覽器禁止擴充功能影響其內建頁面(像是 chrome://version 或是 about:addons與其他擴充功能頁面。每個瀏覽器都會限制只能在其擴充功能商店上安裝擴充功能如 Chrome 線上應用程式商店或 AMO。",
"description": "Sub-note in the toolbar pop-up when on a URL Stylus can't affect"
},
"cm_matchHighlightSelection": {
"message": "僅段",
"description": "Style editor's 'highglight' drop-down list option: highlight the occurrences of currently selected text"

View File

@ -129,9 +129,12 @@ function filterStyles({
exposeIframes: prefs.get('exposeIframes'),
};
if (matchUrl && matchUrl.startsWith(URLS.chromeWebStore)) {
// CWS cannot be scripted in chromium, see ChromeExtensionsClient::IsScriptableURL
// https://cs.chromium.org/chromium/src/chrome/common/extensions/chrome_extensions_client.cc
if (matchUrl && (
// Web Store doesn't run content scripts
matchUrl.startsWith(URLS.browserWebStore) ||
// Chrome 61.0.3161+ doesn't run content scripts on NTP
URLS.chromeProtectsNTP && matchUrl.startsWith('chrome://newtab/')
)) {
return asHash ? {} : [];
}

View File

@ -21,18 +21,30 @@ const URLS = {
// CWS cannot be scripted in chromium, see ChromeExtensionsClient::IsScriptableURL
// https://cs.chromium.org/chromium/src/chrome/common/extensions/chrome_extensions_client.cc
chromeWebStore: FIREFOX ? 'https://addons.mozilla.org/' : (
OPERA ? 'https://addons.opera.com/' : 'https://chrome.google.com/webstore/'
),
browserWebStore:
FIREFOX ? 'https://addons.mozilla.org/' :
OPERA ? 'https://addons.opera.com/' :
'https://chrome.google.com/webstore/',
supported: new RegExp(
'^(file|ftps?|http)://|' +
`^https://${FIREFOX ? '(?!addons\\.mozilla\\.org)' : (
OPERA ? '(?!addons\\.opera\\.com)' : '(?!chrome\\.google\\.com/webstore)'
)}|` +
'^' + chrome.runtime.getURL('')),
// Chrome 61.0.3161+ doesn't run content scripts on NTP https://crrev.com/2978953002/
// TODO: remove when "minimum_chrome_version": "61" or higher
chromeProtectsNTP:
parseInt(navigator.userAgent.match(/Chrom\w+\/(?:\d+\.){2}(\d+)|$/)[1]) >= 3161,
supported: null,
};
URLS.supported = new RegExp(
'^(file|ftps?|http)://|' +
`^https://(?!${
URLS.browserWebStore.split('://')[1].replace(/\./g, '\\.')
})|` +
(URLS.chromeProtectsNTP
? '^chrome://(?!newtab)/|'
: '') +
'^' + chrome.runtime.getURL('')
);
let BG = chrome.extension.getBackgroundPage();
if (!BG || BG !== window) {
@ -134,7 +146,7 @@ function getActiveTabRealURL() {
function getTabRealURL(tab) {
return new Promise(resolve => {
if (tab.url !== 'chrome://newtab/') {
if (tab.url !== 'chrome://newtab/' || URLS.chromeProtectsNTP) {
resolve(tab.url);
} else {
chrome.webNavigation.getFrame({tabId: tab.id, frameId: 0, processId: -1}, frame => {
@ -191,7 +203,7 @@ function activateTab(tab) {
function stringAsRegExp(s, flags) {
return new RegExp(s.replace(/[{}()[\]/\\.+?^$:=*!|]/g, '\\$&'), flags);
return new RegExp(s.replace(/[{}()[\]\\.+*?^$|]/g, '\\$&'), flags);
}