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