SwVitaliy

Untitled

Oct 16th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. function get(selector, ctx) {
  2. return (ctx || document).querySelectorAll(selector);
  3. }
  4. var getScriptNode = function () {
  5. var re = /http:\/\/js.smi2.ru\/data\/js\/(\d+)\.js\b/;
  6.  
  7. var scripts = get('script', document.body);
  8.  
  9. var cmp, id = null, script = [].filter.call(scripts, function (el) {
  10. if (id !== null) {
  11. return false;
  12. }
  13. cmp = el.src.match(re);
  14. if (cmp) {
  15. id = cmp[1];
  16. return true;
  17. }
  18. })[0];
  19.  
  20. return script;
  21. };
  22. unsafeWindow.document.addEventListener('load', function() { unsafeWindow.alert('123'); }, false);
  23. unsafeWindow.document.addEventListener('DOMContentLoaded',
  24. function() {
  25. // console.log('UserScript', getScriptNode());
  26. unsafeWindow.alert('UserScript');
  27. }, false);
Advertisement
Add Comment
Please, Sign In to add comment