1

I'm using the Chrome browser with the Tampermonkey extension. I need to write a script that can run on the Google Trends page, but after several trials and errors, I still can't get it work.

My code:

// ==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!");
});
4

1 回答 1

0

我建议您将其转换为 Google Chrome 扩展程序。

你需要一个:

清单.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
}

脚本.js

$(document).ready(function(){
    alert("This script works!");
});

完成,工作:)

从 Google Chrome 的扩展选项卡中将其加载为未打包的扩展。

于 2014-06-05T02:39:21.080 回答