Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to run working javascript onload after delay
    primarykey
    data
    text
    <p>I am trying to make a greasemonkey script that will run the following code. I have tested it and it definitely works via URL (javascript: blah blah;) minus the comment of course:</p> <pre><code>// Your country code var cc = 'net'; var j = document.getElementsByTagName('td'); for (i=0; i &lt;= j.length; i++) { if (j[[i]].innerHTML.indexOf('points - punishment #A') &gt; 0 &amp;&amp; j[[i]].innerHTML.length == 30) { var k = j[[i]].innerHTML; j[[i]].innerHTML = k.slice(0, 23) + '&lt;a href="http://www.example.' + cc + '/admin.php?screen=affront_tool&amp;mode=view_punishment&amp;punishment_id=' + k.slice(25) + '"&gt;' + k.slice(23) + '&lt;/a&gt;'; } else if (j[[i]].innerHTML.indexOf('points - punishment #A') &gt; 0 &amp;&amp; j[[i]].innerHTML.length == 29) { var k = j[[i]].innerHTML; j[[i]].innerHTML = k.slice(0, 22) + '&lt;a href="http://www.example.' + cc + '/admin.php?screen=affront_tool&amp;mode=view_punishment&amp;punishment_id=' + k.slice(24) + '"&gt;' + k.slice(22) + '&lt;/a&gt;'; } else if (j[[i]].innerHTML.indexOf('points - punishment') &gt; 0 &amp;&amp; j[[i]].innerHTML.length &lt;= 67) { var k = j[[i]].getElementsByTagName('a')[0]; var l = 'http://www.example.' + cc + '/admin.php?screen=affront_tool&amp;mode=view_punishment&amp;punishment_id=' + k.getAttribute('href').slice(19); k.setAttribute('href', l); } } </code></pre> <p>Unfortunately this script works on an element of the page dynamically generated up to ten seconds after load (expect about three), which makes things difficult. I've tried numerous ways of attaching the script as an "onload" attribute to the body with a setTimeout of ten thousand ms, to no avail. Perhaps I should be trying a different method, or I've repeated a simple mistake in the process? Could someone show me how they would do it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload