Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // ==UserScript==
  2. // @include *.m.wikipedia.org/*
  3. // ==/UserScript==
  4.  
  5. (function(){
  6.  
  7. window.opera.addEventListener("BeforeScript", patch_scripts);
  8. function patch_scripts(UserJSEvent){
  9. var script = UserJSEvent.element;
  10.  
  11. // ,r.addEventListener("load",function(){r.classList.add("image-lazy-loaded"),e.parentNode&&e.parentNode.replaceChild(r,e),
  12. // ''.replace(/[.*+?^${}()|[\]\\\/]/g, '\\$&');
  13.  
  14. var pattern = /,([\w$]+\.addEventListener\("load",function\(\)\{[\w$]+\.classList\.add\("image-lazy-loaded"\)),([\w$]+\.parentNode&&[\w$]+\.parentNode\.replaceChild\([\w$]+,[\w$]+\)),/;
  15. var fixed = ",$2,$1,";
  16.  
  17. if (!script.src && pattern.test(script.text)){
  18. script.text = script.text.replace(pattern, fixed);
  19. console.log("lazy-load patched");
  20. }
  21. }
  22.  
  23. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement