1

I have written this userscript.

It's 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.


The problem that, whenever I open such a band page for the first time
the script is not executed, unless I do a page reload (F5) - then it always executed.

I've already tried: enclosing the whole script with either of these: window.addEventListener('load', function() {
or
window.onload = function () { ... MY CODE... }, false);
or, based on this answer

window.addEventListener ("load", Greasemonkey_main, false);

function Greasemonkey_main () {

    //***** MY CODE
}  

or, additionally, even enclosing only line 104 of the script
(which initially calls two functions, to add the column and make it sortable) with
window.addEventListener('load', function() {... MY CODE... }, false);
but without success.

Community
  • 1
  • 1
darkred
  • 591
  • 5
  • 28
  • 2
    search for "wait for key elements" – Kat Cox Oct 16 '14 at 15:10
  • Do you maybe have the website loading partial content? – Ian Hazzard Oct 16 '14 at 15:14
  • 1
    Try rewriting your script using [waitForKeyElements](http://stackoverflow.com/a/11197969/331508), or similar. If you get stuck on that, open a new question. (Hint: also use `@require` for jQuery and tablesorter.) – Brock Adams Oct 16 '14 at 16:57
  • Thanks for your useful comments, Kat Cox and Brock. Brock, ok, I just opened this [new question](http://stackoverflow.com/questions/26416049/greasemonkey-using-the-waitforkeyelements-utility-how-to-call-a-function-aft) because waitForKeyElements syntax seems too diffucult for me. Thanks for the hint, too. – darkred Oct 17 '14 at 00:28

0 Answers0