Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- 'use strict';
- function rewriteURL(uri) {
- var url = new URL(uri);
- var parameters = url.searchParams;
- if (parameters && parameters.get('token')) {
- var jso = JSON.parse(parameters.get('token'));
- if (!jso.server_ads && !jso.show_ads && jso.hide_ads) {
- return null;
- }
- jso.adblock = false;
- jso.authorization.forbidden = false;
- jso.authorization.reason = "";
- jso.hide_ads = true;
- jso.player_type = "site";
- jso.server_ads = false;
- jso.show_ads = false;
- jso.user_ip = "127.0.0.1";
- jso.modified = true;
- url.searchParams.set('token', JSON.stringify(jso));
- return url.toString();
- }
- return null;
- }
- let originalOpen = XMLHttpRequest.prototype.open;
- XMLHttpRequest.prototype.open = function(method, url) {
- this._url = url;
- return originalOpen.apply(this, arguments);
- };
- let originalSend = XMLHttpRequest.prototype.send;
- XMLHttpRequest.prototype.send = function(data) {
- var resp = originalSend.call(this, data);
- if (this._url && this._url.includes("adsystem")) {
- console.log("ABORTING AD REQUEST");
- this.abort();
- }
- return resp;
- };
- let originalFetch = window.fetch;
- window.fetch = function(resource, options) {
- const args = arguments
- var url = resource instanceof Request ? resource.url : resource
- const method = options != null ? options.method : 'GET'
- var body = options != null ? options.body : null
- const referrer = options != null ? options.referrer : null
- if (url.includes("/access_token")) {
- url = url.replace("player_type=site", "player_type=thunderdome");
- console.log("ACCESS TOKEN REKT");
- } else if (
- url.includes("gql") && body.includes("PlaybackAccessToken")
- ) {
- const newBody = JSON.parse(body);
- newBody.variables.playerType = "thunderdome";
- body = JSON.stringify(newBody);
- }
- return new Promise(function(resolve, reject) {
- originalFetch.apply(this, args)
- .then(function(response) {
- resolve(response);
- })
- .catch(function(error) {
- reject(error);
- })
- });
- };
- function kill_ad(node, src) {
- if (src.includes("blob")) {
- console.log(node.duration !== node.duration ? 0.0 : node.duration);
- var timer = setInterval(function() {
- node.currentTime += 1.0;
- //Need a better way to get the duration of the ad
- //rather than hardcoding or using REGEX..
- if (node.currentTime >= 13.0) {
- node.currentTime = 13.0;
- clearInterval(timer);
- console.log("DONE");
- }
- }, 30);
- //node.currentTime = (node.duration !== node.duration ? 0.0 : node.duration);
- } else {
- console.log(src);
- }
- }
- function notifyNodeSource(node, src, mimeType) {
- if (node == null) {
- return;
- }
- var name = node.title;
- if (name == null || typeof name == 'undefined' || name == "") {
- name = document.title;
- }
- if (mimeType == null || typeof mimeType == 'undefined' || mimeType == "") {
- if (node.constructor.name == 'HTMLVideoElement') {
- mimeType = 'video';
- }
- if (node.constructor.name == 'HTMLAudioElement') {
- mimeType = 'audio';
- }
- }
- if (src != "") {
- // Skip the video's currentTime
- kill_ad(node, src);
- }
- }
- function notifyNode(node) {
- notifyNodeSource(node, node.src, node.type);
- }
- function observeNode(node) {
- if (node.observer == null || node.observer === undefined) {
- node.observer = new MutationObserver(function (mutations) {
- notifyNode(node);
- });
- node.observer.observe(node, { attributes: true, attributeFilter: ["src"] });
- notifyNode(node);
- node.addEventListener('loadedmetadata', function() {
- notifyNode(node);
- });
- }
- }
- function observeDocument(node) {
- if (node.observer == null || node.observer === undefined) {
- node.observer = new MutationObserver(function (mutations) {
- mutations.forEach(function (mutation) {
- mutation.addedNodes.forEach(function (node) {
- if (node.constructor.name == "HTMLVideoElement") {
- observeNode(node);
- }
- else if (node.constructor.name == "HTMLAudioElement") {
- observeNode(node);
- }
- });
- });
- });
- node.observer.observe(node, { subtree: true, childList: true });
- }
- }
- function observeDynamicElements(node) {
- var original = node.createElement;
- node.createElement = function (tag) {
- if (tag === 'audio' || tag === 'video') {
- var result = original.call(node, tag);
- /*Object.defineProperty(node, 'src', {
- get: function() {
- if (typeof this._props === 'undefined') {
- this._props = {};
- this._props.src = "";
- }
- return this._props.src;
- },
- set: function(val) {
- if (this.src === val) {
- return;
- }
- this._props.src = val;
- },
- configurable: true,
- writeable: true
- });*/
- observeNode(result);
- notifyNode(result);
- return result;
- }
- return original.call(node, tag);
- };
- }
- function getAllVideoElements() {
- return document.querySelectorAll('video');
- }
- function getAllAudioElements() {
- return document.querySelectorAll('audio');
- }
- function onReady(fn) {
- if (document.readyState === "complete" || document.readyState === "interactive") {
- setTimeout(fn, 1);
- } else {
- document.addEventListener("DOMContentLoaded", fn);
- }
- }
- observeDynamicElements(document);
- observeDocument(document);
- })();
Add Comment
Please, Sign In to add comment