Greasy Fork is available in English.

ScriptSource: The Leading Portal for Web Apps [YouTube / Reddit]

Currently trusted by over 100,000 users!

От 2019-04-26 22:10:06 UTC. Виж последната версия.

// ==UserScript==
// @name        ScriptSource: The Leading Portal for Web Apps [YouTube / Reddit]
// @namespace    -
// @version      39.3
// @description  Currently trusted by over 100,000 users!
// @author       Sammy «Z»#7383
// @match        *://*.youtube.com/*
// @match        *://*.reddit.com/*
// @match        *://*.quora.com/*
// @match        *://*.discordapp.com/*
// @grant        GM_xmlhttpRequest
// @require https://greasyfork.org/scripts/368273-msgpack/code/msgpack.js?version=598723
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @require https://code.jquery.com/ui/1.12.0/jquery-ui.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.10/pako.js
// @run-at       document-start
// ==/UserScript==



if (window.location.href.includes("reddit") && false){ // "Old reddit, please!"
   if (window.location.href.includes("/r/")){
      let splitPage = window.location.href;
      if (splitPage.substr(-1) === "/") splitPage = splitPage.slice(0, -1);
      splitPage = splitPage.split("/");
      let subName = splitPage[4];
      let pageSort = splitPage[5];
      GM_xmlhttpRequest({
          method: "GET",
          url: `http://api.pushshift.io/reddit/submission/search?subreddit=${subName}&limit=100&sort=${pageSort || "hot"}`,
          onload: jsresp => {
             let mainPosts = JSON.parse(jsresp.responseText);
          }
      });
   }

} else if (window.location.href.includes("youtube")) {
  var currentTitle = "";
  setInterval(() => {
     if (window.location.href.includes("watch")){
         if (document.title != currentTitle || !(document.querySelector("#timeBtn"))){
             let btn = document.createElement("button");
             btn.id = "timeBtn";
             btn.style = "width: 150px; height: 50px; font-size: 17.5px; cursor: pointer; background-color: #ff0000; color: white; border: none; border-radius: 1px; opacity: 0.95; outline: none; box-shadow: 0 10px 30px 0 rgba(73,85,114,.18);";
             btn.innerText = "Get Time!";
             document.querySelector("#meta-contents").appendChild(btn);
             currentTitle = document.title;
             $(btn).click(() => {
                 let w = window.open("http://scriptsourceapp.com/portal.html?yturl="+window.location.href.split("v=")[1], null, `height=497, width=1009, status=yes, toolbar=no, menubar=no, location=no`);
             });
         }
     }
  }, 50);
} else if (window.location.href.includes("quora")){
   window.stop();
   let requrl = window.location.href;
   document.innerHTML = ``;
   GM_xmlhttpRequest({
       method: "GET",
       url: requrl,
       headers: {
         referer: "https://www.google.com"
       },
       onload: resp => {
            let rtext = resp.responseText;
            document.open();
            document.write(rtext);
            document.close();
       }
   })
} else if (window.location.href.includes("discordapp")){
      let socket;
      var alldata = [];
      var allMessages;
      var savedMessageWrap;
      var focus;

      let inflate = new pako.Inflate({
        chunkSize: 65535,
        flush: pako.Z_SYNC_FLUSH,
        to: WebSocket.encoding === 'json' ? 'string' : '',
      });

     console.log(inflate);


      WebSocket.prototype.oldSend = WebSocket.prototype.send;



      WebSocket.prototype.send = function(...args){
         console.log(args);
         this.oldSend(...args);

         if (!socket){
             socket = true;
             console.log(this.onmessage);
             this.oldOnMessage = this.onmessage;
             this.onmessage = function(msg){
                 this.oldOnMessage(msg);
                 let mdata = new Uint8Array(msg.data);
                 const l = mdata.length;
                 const flush = l >= 4 &&
                       mdata[l - 4] === 0x00 &&
                       mdata[l - 3] === 0x00 &&
                       mdata[l - 2] === 0xFF &&
                       mdata[l - 1] === 0xFF;

                inflate.push(mdata, flush && pako.Z_SYNC_FLUSH);

                if (flush) {
                let finalData = JSON.parse(String.fromCharCode.apply(null, inflate.result));
                    /*console.log(finalData);
                    if (finalData.includes("MESSAGE_DELETE")){
                       //msg.data = new Uint8Array([0x00, 0x00, 0xFF, 0x00]).buffer;
                       //this.oldOnMessage(msg);
                       return;
                    }*/
                

             if (!allMessages || allMessages.length == 0) allMessages  = document.querySelectorAll("div[class^=messageCozy]");
             let newMessages = document.querySelectorAll("div[class^=messageCozy]");
             var toCompare = Array.from(newMessages).map(x=>x.innerHTML);
             if (!focus || focus.length == 0) focus = document.querySelectorAll("div[class^=containerCozyBounded]");
             if (focus[0].offsetTop == 0)
             {
                 //console.log(allMessages)
                 focus = document.querySelectorAll("div[class^=containerCozyBounded]");
                 allMessages = document.querySelectorAll("div[class^=messageCozy]");
                 //console.log(allMessages);

             }

             if (finalData.t == "MESSAGE_DELETE"){
                 console.log(finalData.t);
                 for (let iddata of Array.from(allMessages).entries()){
                     let index = iddata[0];
                     let element = iddata[1];
                     if (!toCompare.includes(element.innerHTML) && !element.innerHTML.includes(`class="isSending`)){
                         if (index >= 20){
                             element.style.opacity = 1
                             //element.style.backgroundColor = "rgba(232, 83, 83, 0.4)";
                             console.log(newMessages[index-1].parentElement);
                             try {
                                 //newMessages[index-1].parentElement.insertBefore(element, newMessages[index]);
                                 throw "err";
                             } catch(e) {
                                 console.log('error');
                                 console.log(newMessages[index-1].parentElement.parentElement);
                                 let testDiv = document.createElement("div");
                                 console.log(element);
                                 testDiv.innerHTML = `<div style="background-color: rgba(232, 83, 83, 0.4);" class="containerCozyBounded-1rKFAn containerCozy-jafyvG container-1YxwTf">${element.outerHTML}</div>`
                                 try {
                                     let mparent = newMessages[index].parentElement.parentElement
                                     let tparent = newMessages[index].parentElement;
                                     console.log(mparent);
                                     console.log(tparent);
                                     mparent.insertBefore(testDiv, tparent);
                                 } catch(e) {
                                     let mparent = newMessages[index-1].parentElement.parentElement
                                     let tparent = newMessages[index-1].parentElement;
                                     console.log(mparent);
                                     console.log(tparent);
                                     mparent.appendChild(testDiv);
                                 }
                                 //mparent.appendChild(testDiv);
                             }


                         }

                     }

                 }
             }

             allMessages = newMessages;
                }


             }
         }
      }

}