Greasemonkey (using the waitForKeyElements utility) - how to call a function after a specific element has been displayed on screen

前端 未结 1 2013
傲寒
傲寒 2021-01-16 05:37

(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 DISCOGR

相关标签:
1条回答
  • 2021-01-16 06:24

    Assuming the appendColumn function works, as is, on reloads; then you would rewrite it slightly and call it from waitForKeyElements().

    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...
        //...
    
    0 讨论(0)
提交回复
热议问题