Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        localhost iframe script
  3. // @namespace   http://localhost
  4. // @include     http://localhost/
  5. // @version     1
  6. // @grant       none
  7. // ==/UserScript==
  8.  
  9. alert("testno na localhost!");
  10.  
  11. 'allow pasting'
  12. /*
  13.  * In window A's scripts, with A being on <http://www.nepremicnine.net:8080>:
  14.  */
  15.  
  16. var popup = window.open("", "", "width=200, height=100");
  17.  
  18. // When the popup has fully loaded, if not blocked by a popup blocker:
  19.  
  20. // This does nothing, assuming the window hasn't changed its location.
  21. popup.postMessage("The user is 'bob' and the password is 'secret'",
  22.                   "https://secure.nepremicnine.net");
  23.  
  24. // This will successfully queue a message to be sent to the popup, assuming
  25. // the window hasn't changed its location.
  26. popup.postMessage("hello there!", "http://localhost");
  27.  
  28. function receiveMessage(event)
  29. {
  30.  
  31.   console.log("GreaseMOnkey script");
  32.   // Do we trust the sender of this message?  (might be
  33.   // different from what we originally opened, for example).
  34.   if (event.origin !== "http://localhost")
  35.     return;
  36.  
  37.   // event.source is popup
  38.   // event.data is "hi there yourself!  the secret response is: rheeeeet!"
  39. }
  40. window.addEventListener("message", receiveMessage, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement