Advertisement
Guest User

Untitled

a guest
May 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function repair() {
  2.    
  3.         function preparePage() {
  4.             document.getElementsByTagName('body')[0].innerHTML = '';
  5.             var ifrm = document.createElement("iframe");
  6.             ifrm.setAttribute("src", window.location.href);
  7.             ifrm.setAttribute("id", "iframe");
  8.             ifrm.setAttribute("onload", "repair()");
  9.             ifrm.style.position = 'fixed';
  10.             ifrm.style.top = '0px';
  11.             ifrm.style.left = '0px';
  12.             ifrm.style.bottom = '0px';
  13.             ifrm.style.right = '0px';
  14.             ifrm.style.width = '100%';
  15.             ifrm.style.height = '100%';
  16.             ifrm.style.border = 'none';
  17.             ifrm.style.margin = '0';
  18.             ifrm.style.padding = '0';
  19.             ifrm.style.overflow = 'hidden';
  20.             document.body.appendChild(ifrm);
  21.         }
  22.  
  23.     function periodicRepair(){
  24.         //console.log('repair start');
  25.        
  26.         var iframe = document.getElementById("iframe");
  27.         var list = iframe.contentWindow.document.getElementsByTagName('a');
  28.         for (var index = 0; index < list.length; index++) {
  29.             if (list[index].innerHTML.search('webm') > -1 && list[index].innerHTML.search('img') > -1) {
  30.                 list[index].innerHTML = list[index].innerHTML.replace('img', 'video controls loop');
  31.             }
  32.         }
  33.         //console.log('repair ends');
  34.         //setTimeout(periodicRepair,3000);
  35.     }
  36.  
  37.     function fixUrl(){
  38.         var iframeurl = document.getElementById("iframe").contentWindow.location.href;
  39.         window.history.pushState('', '', iframeurl);
  40.     }
  41.     if(document.getElementById('iframe') == null){
  42.         preparePage();
  43.     }
  44.     fixUrl();
  45.     periodicRepair();
  46.    
  47.     //setTimeout(periodicRepair,3000);
  48.  
  49. }
  50. repair();
  51.  
  52. /*
  53. This will fix the vídeo display with the site.
  54.  
  55. To use this, you must be in the cuberope's e621 mobile or it's mirrors before use this script
  56.  
  57. You can run this anytime inside cuberope's e621 mobile, the script will try to preserve your search
  58.  
  59. (Pick one)
  60. *Paste this script in the URL bar (some browsers will cut the [i]javascript:[/i] part, you need to type [i]javascript:[/i] in the beginning
  61. *Paste this script in the console
  62. *Create a bookmarklet, then, use it
  63.  
  64. [code]javascript:function repair(){function preparePage(){document.getElementsByTagName("body")[0].innerHTML="";var ifrm=document.createElement("iframe");ifrm.setAttribute("src",window.location.href),ifrm.setAttribute("id","iframe"),ifrm.setAttribute("onload","repair()"),ifrm.style.position="fixed",ifrm.style.top="0px",ifrm.style.left="0px",ifrm.style.bottom="0px",ifrm.style.right="0px",ifrm.style.width="100%",ifrm.style.height="100%",ifrm.style.border="none",ifrm.style.margin="0",ifrm.style.padding="0",ifrm.style.overflow="hidden",document.body.appendChild(ifrm)}function periodicRepair(){for(var iframe=document.getElementById("iframe"),list=iframe.contentWindow.document.getElementsByTagName("a"),index=0;index<list.length;index++)list[index].innerHTML.search("webm")>-1&&list[index].innerHTML.search("img")>-1&&(list[index].innerHTML=list[index].innerHTML.replace("img","video controls loop"))}function fixUrl(){var iframeurl=document.getElementById("iframe").contentWindow.location.href;window.history.pushState("","",iframeurl)}null==document.getElementById("iframe")&&preparePage(),fixUrl(),periodicRepair()}repair();
  65. [/code]
  66.  
  67. Because this is a [s]hack[/s]quick fix, the script will fix video display when page finish the loading. If the page has multiple gifs and heavy images, the videos will only appear when they are fully loaded
  68. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement