标签: greasemonkey

Greasemonkey:爱还是恨?

作为用户,我们喜欢Greasemonkey的力量.作为开发人员,它可以使事情复杂化.

有些主张防御性地禁用用户脚本; 其他人愿意为了捍卫他们而死.

有中间地带吗?我们如何才能减少用户和不道德广告商之间进化军备竞赛的威胁?

javascript greasemonkey

2
推荐指数
2
解决办法
524
查看次数

有没有办法将值传递给GM​​_xmlhttprequest?

如下所示:

如何从GM_xmlhttprequest返回值?

我有一个异步的脚本.我想传递一个值INTO这个函数,这样当调用onload函数时我可以用它来显示在网页中.

我遇到的挑战是,每次将其传递给函数时,此值都会发生变化.

所以,例如,如果我传入'abc','def','xyz'.

我最终会

xyz
xyz
xyz
Run Code Online (Sandbox Code Playgroud)

代替

abc
def
xyz
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是,如何将值传递给此函数,以便函数的每次调用都知道完成后要显示的内容?

javascript greasemonkey asynchronous gm-xmlhttprequest

2
推荐指数
1
解决办法
734
查看次数

任何可以在谷歌浏览器中使用的Jquery运行Greasemonkey脚本?

你有任何链接\例如Greasemonkey脚本与Jquery在Google Chrome中有效吗?

jquery greasemonkey google-chrome

2
推荐指数
1
解决办法
736
查看次数

修改GM_setValue和GM_getValue以进行交叉表通信:如何访问Firefox首选项变量?

我有一个与我的GM用户脚本相关的新问题.

此脚本的目的是从外部域检索数据.我对Firefox的第一次尝试让我设计了一个页面,我的表单被填充,iframe嵌入了外部页面.通过使用setInterval并识别它是顶部窗口,或者如果我们在iframe中,我成功使用GM_setValue和GM_getValue来获取数据.

但是使用IE(IE7PRO),我发现我能够将我的脚本分成2个脚本:一个只处理表单,另一个处理外部域.IE7PRO提供了可在产品的任何选项卡/页面上检索的等效函数(PRO_getValue和PRO_setValue).唯一的区别是它适用于交叉表/页面,所以我不必在我自己的页面上包含iframe,我可以为外部域打开自己的选项卡,这个选项卡大约要好一百万倍(至少是. ..)!

我在Firefox上尝试过相同的操作,但显然无效.我已经浏览了这些函数文档,看来在Firefox中,数据存储在Preferences(about:config to access)中.

那么,有没有办法可以修改GM_getValue,添加参数,因为值存储在这个模型中: greasemonkey.scriptvals.namespace/script_name.value_name

有没有办法在Firefox中,在Greasemonkey用户脚本/ Javascript中访问首选项的值,是什么语法?

谢谢 ;-)

javascript firefox greasemonkey

2
推荐指数
1
解决办法
1765
查看次数

如何使用Greasemonkey调用现有视频的Youtube-Flash-API

我想写一个Greasemonkey脚本来检测网站上的YouTube视频何时开始播放以阻止我的winamp播放音乐.一切正常,我的脚本检测到视频,启用API以及onYouTubePlayerReady调用事件.但我不知道如何注册onStateChange回调,这是我的代码:

unsafeWindow.onYouTubePlayerReady = function (playerId)
{
    alert('Visible');

    document.getElementById(playerId).addEventListener('onStateChange', 'stateChanged');    

    alert('Not visible, so the line above crashes');
}

unsafeWindow.stateChanged = function (state)
{
    alert('never called, too');
}
Run Code Online (Sandbox Code Playgroud)

这个问题有解决方案还是不可能?

javascript greasemonkey youtube-api userscripts

2
推荐指数
1
解决办法
1198
查看次数

Greasemonkey脚本自动修改具有特定id值的URL

我想将网址从"http://example.com/products/description/product123/index.html"更改为"http://example.com/f123456/products/description/product123/index.html".对于来自特定站点(只有一个)的每个链接,我需要像在示例中那样更改,在链接的基础之后添加代码,之后继续使用普通链接.

而更具体的,这里是我想用我的脚本来修改链接:http://www.f64.ro/http://www.f64.ro/f444618/的每一个环节,产品等.

我尝试了一些我找到的东西,但它不起作用,我不知道出了什么问题.

    // ==UserScript==
    // @name     F64.ro
    // @include  http://www.f64.ro/*
    // ==/UserScript==

    var targID      = "f444618/";
    var targLink    = document.querySelector ("#" + targID);
    targLink.href  += targID + "\/";
Run Code Online (Sandbox Code Playgroud)

谢谢!

url greasemonkey replace

2
推荐指数
1
解决办法
1万
查看次数

我的Greasemonkey脚本如何自动重新加载页面,并自动单击按钮?

我是JavaScript的初学者.我需要知道这是否可行然后如果可行,该怎么做.

我想创建一个Greasemonkey脚本,它会每小时自动重新加载一个网页,然后在重新加载页面后,我希望它为我点击一个按钮.

那可能吗?

javascript greasemonkey click reload

2
推荐指数
1
解决办法
8160
查看次数

setTimeout花费的时间比应该的长

有人可以解释一下为什么脚本(下面带有setTimeout命令)在Greasemonkey中执行所需的时间(400-500毫秒)比在Firefox控制台中执行的时间长100毫秒(400-500毫秒)吗?

var start = new Date ().getTime ();
console.log (
    new Date ().getHours ()+" : " + new Date ().getMinutes () 
    + " : " + new Date ().getSeconds () + " : " 
    + new Date ().getMilliseconds () 
); 

setTimeout (foo,100);
//foo ();

function foo () {
    var time = new Date () - start;
    console.log ("Execution time: " + time + "ms");
}
Run Code Online (Sandbox Code Playgroud)

这很奇怪,因为如果我切换setTimeout(foo,100)为pure foo(),那么Greasemonkey和Firefox控制台都将以闪电般的速度(〜10毫秒)执行它。

javascript firefox greasemonkey settimeout setinterval

2
推荐指数
1
解决办法
1845
查看次数

如何使用confirm()更改为Fullscreen整个网页?

我想要在确认框中单击"确定"时整个网页转到全屏,但只有这样才会出现错误TypeError: docelem.requestFullscreen is not a function.我尝试了所有但没有...

var conf = confirm("Fullscreen mode?");
var docelem = document.documentElement;
if (conf == true) {
    docelem.requestFullscreen();
}
else if (conf == true) {
    docelem.mozRequestFullScreen();
}
else if (conf == true) {
    docelem.webkitRequestFullScreen();
}
else if (conf == true) {
    docelem.msRequestFullscreen();
}
Run Code Online (Sandbox Code Playgroud)

一些解决方案 或者确认()是不可能的?因为有一个按钮工作:

(function () {
    var fullscreenon = document.getElementById("fullscreenbutton");//button Id
    if (fullscreenon) {
        fullscreenon.addEventListener("click", function () {
            var docelem = document.documentElement;
            if (docelem.requestFullscreen) {
                docelem.requestFullscreen();
            }
            else if (docelem.msRequestFullscreen) {
                docelem.msRequestFullscreen();
            } …
Run Code Online (Sandbox Code Playgroud)

html javascript firefox confirm greasemonkey

2
推荐指数
1
解决办法
7979
查看次数

未定义EncodeURIcomponent

我正在玩GreaseMonkey沙箱,尝试制作一个脚本来将加载的页面转发到另一台服务器以通过POST处理。这是脚本:

// ==UserScript==
// @name        Mirror Page
// @namespace   mailto:linkhyrule5@gmail.com
// @description POSTs page to dynamic page mirror
// @include     http://*
// @include     https://*
// @version     1
// @grant       GM_xmlhttpRequest
// ==/UserScript==

var ihtml = document.body.innerHTML;
GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://localhost:5723/index.php',
    data: "PageContents=" + encodeURIcomponent(ihtml) + "\nURL=" + encodeURIcomponent(document.URL),
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
Run Code Online (Sandbox Code Playgroud)

无论如何,encodeURIcomponent is not defined即使它是一个全局函数,我也应该得到它,并且应该可以在JavaScript所在的任何地方使用。我以为我误会了什么?

javascript json greasemonkey

2
推荐指数
1
解决办法
4339
查看次数