Greasemonkey(使用waitForKeyElements实用程序) - 如何在屏幕上显示特定元素后调用函数 [英] Greasemonkey (using the waitForKeyElements utility) - how to call a function after a specific element has been displayed on screen
问题描述
(继续我的这个问题)。< br>
我一直在写此用户说明。
打开乐队页面时(示例)您登陆DISCOGRAPHY>完整的离体记录。
我的脚本适用于DISCOGRAPHY选项卡
及其子标签(COMPLETE DISCOGRAPHY,MAIN,LIVES,DEMOS,MISC):
它将评论列分成两部分并使表格可排序。
(In continuance to this question of mine).
I've been writing this userscript for the site metal-archives.com.
When opening a band page (example) you land to DISCOGRAPHY>COMPLETE DISCOGRAPHY.
My script applies to that DISCOGRAPHY tab
and it's sub-tabs (COMPLETE DISCOGRAPHY, MAIN, LIVES, DEMOS, MISC) :
it splits the column "Reviews" in two and makes the table sortable.
我最初想要(在我的脚本中使用 waitForKeyElements
实用程序在greasemonkey中)
a函数(根据内容添加一个列, appendColumn(x)
)
在之后被称为 DISCOGRAPHY> COMPLETE DISCOGRAPHY中的表格已经完全显示(我认为这是:在表格的最后一个标题显示之后)。
id
该表的最后一个标题(MISC。)的值已存储在此数组位置: myArray [end]
I want initially (using the waitForKeyElements
utility in my script in greasemonkey)
a function (which adds a column to the table, based on it's contents, appendColumn(x)
)
to be called after the table inside DISCOGRAPHY > COMPLETE DISCOGRAPHY has been completely displayed (I think this as: after the last header of the table has been displayed).
The id
value of the last header of that table (MISC.) is already stored in this array position: myArray[end]
所以,到目前为止我失败的尝试(基于这个答案) 用户Brock Adams在我的初始问题中建议的)是以下变体:
So, my failed tries so far (based on this answer that user Brock Adams kindly suggested in my initial question) are variants of:
function appendColumn(x){....}
function triggerCall(jNode) {
appendColumn(0); or --> jNode.appendColumn(0);
}
waitForKeyElements (myArray[end], triggerCall); // no parentheses after triggerCall
推荐答案
假设 appendColumn
函数在重新加载时有效;然后你会稍微重写它并从waitForKeyElements()调用它。
Assuming the appendColumn
function works, as is, on reloads; then you would rewrite it slightly and call it from waitForKeyElements().
你不需要大部分的rigamorole,只需使用类名显示选择器的
和 discog
。像这样:
You don't need most of that rigamorole, just use class names display
and discog
for the selector. Like so:
waitForKeyElements (".display.discog", appendColumn);
function appendColumn(jNode) {
var tbl = jNode[0]; // table reference
var i;
var newCell, newText;
var tr = tbl.tHead.children[0],
th = document.createElement('th');
// THE REST OF THE FUNCTION IS THE SAME...
//...
这篇关于Greasemonkey(使用waitForKeyElements实用程序) - 如何在屏幕上显示特定元素后调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!