[英]How to make greasemonkey run a specfic javascript: function?
Can somebody help me loop the following function and make it run every 5 seconds: 有人可以帮我循环以下功能,使其每5秒运行一次:
javascript:listAction(
'editObjectSingle','inforUpdateAction','divEditObjectSingle','formEditObjectSingle'
);
for the specific website google.com? 特定网站google.com?
I'm still new to this and unsure how to write it 我还是这个新手,不确定如何写
// ==UserScript==
// @name Google
// @description Google
// @include Google.com
// ==/UserScript==
// initiate
This is what I have so far, not sure how to add other stuff. 到目前为止,这是我所掌握的,不确定如何添加其他内容。 Thanks!
谢谢!
See, also: 也可以看看:
For the default @grant
setting ( @grant none
), calling a page's javascript is relatively straightforward. 对于默认的
@grant
设置 ( @grant none
),调用页面的javascript相对简单。
If, and only if, listAction
is a global function on the page (it probably is), then you can call it like so: 当且仅当
listAction
是页面上的全局函数 (可能是)时,您可以这样调用它:
// ==UserScript==
// @name Google function spammer
// @match *://*.google.com/*
// @description Spam the snot out of the listAction function on Google.
// @grant none
// ==/UserScript==
var updateTimer = setInterval ( function () {
//-- The function will not always exist (right away).
if (typeof listAction === "function") {
listAction (
'editObjectSingle', 'inforUpdateAction',
'divEditObjectSingle', 'formEditObjectSingle'
);
}
},
5 * 1000 // 5 seconds
);
Note that the @include
directive in the question is off and the replacement with @match
, above. 请注意,问题中的
@include
指令已关闭,并在上方替换为@match
。
Also beware that if the function is called from a click
handler, etc., it may expect/require a context ( this
). 还应注意,如果从
click
处理程序等调用该函数,则可能期望/需要一个上下文( this
)。 In that case, calling it requires more information than is present in this question and probably can be accomplished by programmatically clicking on the control . 在这种情况下,调用它需要的信息比该问题中提供的信息更多,并且可能可以通过以编程方式单击控件来完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.