In Chrome 61.0.3161+ NTP can't be styled anymore
This commit is contained in:
		
							parent
							
								
									b37b2c5246
								
							
						
					
					
						commit
						3b49d83616
					
				|  | @ -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" | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -756,4 +752,4 @@ | |||
| 		"message": "Změňte vzhled webů pomocí správce uživatelských stylů. Stylus umožňuje snadnou instalaci vzhledů a modifikací pro spoustu webů.", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -728,4 +724,4 @@ | |||
| 		"message": "Gestalte das Web neu mit Stylus, dem Style Manager. Stylus ermöglicht dir ganz einfach Themes und Designs für viele populäre Websites zu installieren.", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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": { | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -752,4 +748,4 @@ | |||
| 		"message": "Rediseñe la web con Stylus, un administrador de estilos de usuario. Stylus le permite instalar fácilmente temas y coberturas para muchos sitios populares.", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -620,4 +616,4 @@ | |||
| 		"message": "Stylus はユーザー スタイルを管理するツールで、ウェブのスタイルを変更することができます。Stylus を利用すると、Google、Facebook、YouTube、orkut など、さまざまなサイトに対応したテーマやスキンを簡単にインストールできます。", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -756,4 +752,4 @@ | |||
| 		"message": "Настраивайте стили веб-сайтов с помощью менеджера стилей Stylus. Он позволяет легко установить темы и изменить внешний вид сайтов Google, Facebook, YouTube, Orkut и множества других веб-страниц.", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -760,4 +756,4 @@ | |||
| 		"message": "Stylus 是一个调整网页外观的用户样式管理器。它可让您轻松地为许多热门网站网站安装主题和皮肤。", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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" | ||||
|  | @ -760,4 +756,4 @@ | |||
| 		"message": "用Stylus(一個用戶樣式管理器)重塑網頁。 Stylus 讓你能為诸多主流網站輕鬆的安裝主題和皮膚。", | ||||
| 		"description": "Extension description" | ||||
| 	} | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -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 ? {} : []; | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user