1

I want to add debug function to the page that allows me to click N times given element as one liner JS console call. I have following short script:

// ==UserScript==
// @name     Click given button N times
// @version  1
// ==/UserScript==


console.log("allright im here");
unsafeWindow.clickMe=function(target,n){

  if(!n){
     n=10;
  }
  for(var i=0;i<n;i++){
     target.click();
  }
}

unsafeWindow.test="blelbleb";
console.log(unsafeWindow.clickMe);

but when I try to to invoke that from the page (console) i get this

enter image description here

Why is that? How can I access exported function?

Moreover, clickMe is printed out as Restricted

enter image description here

How to deal with that ?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Antoniossss
  • 31,590
  • 6
  • 57
  • 99
  • When using GM4, you must use the techniques of the duplicate question whether or not `@grant` values are set (when using `unsafeWindow`). Also, `clickMe(null, 10);` would give an error regardless. ... Finally, you should include your GM and browser versions in questions like this. – Brock Adams Sep 12 '18 at 18:09
  • But 1) I have no `@grant` here so `@grant none` 2)does not matter 3) I could include versions indeed. – Antoniossss Sep 12 '18 at 18:46
  • 1
    Nevertheless duplicate answers my issue. I tried exportFunction but in form of `Components.something.exportFunction` but hit the wall since that `something` was undefined for some reasons. Thanks! – Antoniossss Sep 12 '18 at 18:52

0 Answers0