我想为 Google 页面制作一个脚本,例如:chrome://apps/
但 Tampermonkey 似乎无法在这些页面上运行。下面的脚本我应该做什么?
我正在尝试:
// ==UserScript==
// @name Some Script
// @namespace http://tampermonkey.net/
// @version 0
// @description Trying to work in Google pages
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
var myVar = 0;
if(window.location.href === "chrome://apps/"){ //check the URL
if(myVar === 0){
myVar++;
alert("test");
}
}
最佳答案
Chrome 扩展程序(以及 Tampermonkey)无法在任何以 chrome
开头的页面上运行。
Host permissions and content script matching are based on a set of URLs defined by match patterns. A match pattern is essentially a URL that begins with a permitted scheme (
http
,https
,file
, orftp
, and that can contain'*'
characters.
如果扩展程序/脚本可能故意扰乱设置或安装扩展程序,那么 Chrome 将不是一个好地方。
关于javascript - 如何让 Tampermonkey 在 Google `chrome://` 页面上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48960885/