0

I want this piece of code to be executed every 5 second using Greasemonkey. I added it on Greasemonkey but it do not execute.

 var inputs = document.getElementsByClassName('_48-k UFILikeLink');
 for (var i = 0; i < inputs.length; i++) {

 var string = inputs[i].outerHTML;
 var substring = "Unlike this";
 if (string.indexOf(substring) == -1)
     inputs[i].click();

}
Arnold Asllani
  • 155
  • 1
  • 12
  • 1
    Put it in a setInterval. – CollinD Jan 14 '16 at 21:14
  • @CollinD there is one thing I dont understand. When does Greasemonkey execute the script? When page is loading? – Arnold Asllani Jan 14 '16 at 21:20
  • It's configurable I believe. But the default is at `DOMContentLoaded event` (relevant question: http://stackoverflow.com/questions/8772137/understanding-how-greasemonkey-runs-user-scripts) – CollinD Jan 14 '16 at 21:21

1 Answers1

0
// ==UserScript==
// @name        Your script name
// @namespace   *
// @description Your script description
// @author      Your name
// @license     License, e.g. GPLv3
// @include     *
// @version     0.0.1
// @grant       none
// ==/UserScript==

/* code here */

For more info read this: http://www.webmonkey.com/2010/02/get_started_with_greasemonkey/#Example_Project:_Create_a_Floating_Menu_from_Headings

Deep
  • 2,472
  • 2
  • 15
  • 25