Guest User

pluto.tv-add-random-channel-button.user.js

a guest
Jul 5th, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        pluto.tv add random channel button
  3. // @namespace   https://greasyfork.org/en/users/85671-jcunews
  4. // @version     1.0.1
  5. // @license     AGPL v3
  6. // @author      jcunews
  7. // @description Context: https://old.reddit.com/r/userscripts/comments/14q7g82/could_someone_please_make_a_script_that_randomly/
  8. // @match       https://pluto.tv/*
  9. // @grant       none
  10. // @run-at      document-start
  11. // ==/UserScript==
  12.  
  13. ((rj, cl) => {
  14.   rj = Response.prototype.json;
  15.   Response.prototype.json = function() {
  16.     var res = rj.apply(this, arguments);
  17.     if (this.url.includes("/v2/guide/channels")) res.then(obj => cl = obj);
  18.     return res
  19.   };
  20.   function chkPage(clc) {
  21.     if ((clc = document.querySelector('div[class^="channelListContainer-"] .hours span')) && !window.btnrtc) {
  22.       document.querySelector('div[class^="liveTVGuideLayoutContainer-"]').insertAdjacentHTML("beforebegin", `
  23.         <a id="btnrtc" href="#" style="
  24.          position:absolute;z-index:1;left:2.4em;margin-top:-.2em;border-radius:.3em;padding:0 .3em .22em .3em;background:#050;
  25.          color:#fff;text-decoration:none!important;font-size:18px;font-weight:bold;cursor:pointer;
  26.        ">Random Channel</a>`);
  27.       window.btnrtc.onclick = ev => {
  28.         ev.preventDefault();
  29.         if (cl) {
  30.           location.href = cl.data[Math.floor(Math.random() * cl.data.length)].slug
  31.         } else alert("Channel list data is not found due to site changes.")
  32.       }
  33.     }
  34.   }
  35.   setInterval(chkPage, 200)
  36. })()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment