如何在Tampermonkey脚本中包含本地htm页面?

时间:2015-12-23 13:44:44

标签: google-chrome tampermonkey

以下脚本适用于普通网页,但我如何才能将其用于本地.htm文件? (在Chrome浏览器中打开时)

public String getProduct() {

        Client client = Client.create();
        WebResource webResource =       client.resource("http://localhost:8080/product/getProduct");
        InputBean data = new InputBean(1,1); // make sure there's a constructor
        ClientResponse response = webResource.type(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON)
                .post(ClientResponse.class, data);
        return response.getEntity(String.class);
    }

最后一行(// ==UserScript== // @name betterTwitter // @version 0.5 // @namespace http://www.h4xful.net/ // @description Gets rid of the garbage on Twitter's side-panel. // @include http://twitter.com/* // @include https://twitter.com/* // @include file://C:/Users/*.htm ... ... )根本不起作用。脚本不会为示例页面触发。

1 个答案:

答案 0 :(得分:3)

首先,在Chrome的扩展程序设置页面(chrome://extensions/)上,确保Tampermonkey可以访问文件网址:

File URL setting

其次,使用正确的斜杠数格式化@include(或@match)。它几乎总是以file:///开头 例如:

// @include    file:///C:/Users/*.htm
相关问题