无法在Google Trends页面上运行Tampermonkey脚本
-
21-12-2019 - |
题
我正在使用带有tampermonkey扩展的Chrome浏览器。我需要编写一个可以在Google Trends页面上运行的脚本,但在多次试验和错误之后,我仍然无法完成工作。
我的代码:
// ==UserScript==
// @name run on google trends page
// @namespace http://use.i.E.your.googleTrends.com
// @version 0.1
// @description I'm trying to get this script work,please help.
// @match https://www.google.com/trends/explore#q=apple
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @copyright 2012+, You
// ==/UserScript==
$(document).ready(function(){
alert("This script works!");
});
. 解决方案
我建议您将其转换为Google Chrome扩展。
你需要答:
manifest.json
{
"name": "run on google trends page",
"version": "0.1",
"description": "I'm trying to get this script work,please help.",
"homepage_url": "http://use.i.E.your.googleTrends.com",
"content_scripts": [
{
"matches": [
"https://www.google.com/*"
],
"include_globs":[
"*google.com/trends/explore#q=apple*"
],
"js": [
"jquery-2.1.1.min.js",
"script.js"
]
}
],
"manifest_version": 2
}
.
script.js
$(document).ready(function(){
alert("This script works!");
});
.
并完成,工作:)
从Google Chrome的扩展选项卡加载它作为未包装的扩展。
不隶属于 StackOverflow