我正在使用带有Tampermonkey扩展程序的Chrome浏览器。我需要编写一个可以在Google趋势页面上运行的脚本,但经过多次试验和错误后,我仍然无法使其运行。
我的代码:
// ==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!");
});
答案 0 :(得分:0)
我建议您将其转换为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浏览器的扩展程序标签中将其加载为解压扩展名。