Skip to content

Instantly share code, notes, and snippets.

@yokrysty
Last active October 6, 2021 02:48
Show Gist options
  • Save yokrysty/4f676208e26ed73d12021c0ed0d286e2 to your computer and use it in GitHub Desktop.
Save yokrysty/4f676208e26ed73d12021c0ed0d286e2 to your computer and use it in GitHub Desktop.
Tampermonkey script: anti anti ad block in protv plus player
// ==UserScript==
// @name AntiAntiAdBlockProTvPlusPlayer
// @namespace http://tampermonkey.net/
// @version 0.2
// @description anti anti ad block in protv plus player
// @author krysty
// @grant none
// @include https://protvplus.ro/*
// @include https://media.cms.protvplus.ro/*
// @include https://imasdk.googleapis.com/js/core/bridge*.html
// @run-at document-end
// @updateURL https://gist.github.com/yokrysty/4f676208e26ed73d12021c0ed0d286e2/raw/AntiAntiAdBlockProTvPlusPlayer.user.js
// ==/UserScript==
(function() {
'use strict';
(function(open) {
XMLHttpRequest.prototype.open = function(method, url) {
this._url = url;
return open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
(function(send) {
XMLHttpRequest.prototype.send = function(data) {
var b = this._url.indexOf('vasterix.cms.protvplus.ro') >= 0;
if (!b) {
return send.apply(this, arguments);
}
Object.defineProperty(this, "readyState", {
get: function () {
return XMLHttpRequest.DONE;
}
});
Object.defineProperty(this, "status", {
get: function () {
return 200;
}
});
this.onabort = this.onerror = null;
this.abort();
this.onload();
}
})(XMLHttpRequest.prototype.send);
function maybeReplaceElement(el) {
if (el.nodeName != 'SCRIPT') return el;
if (
el.src == 'https://trackad.cz/adtrack.php' ||
el.src == 'https://d1.a4w.ro/_web/grooveskin/grskmak.min.js' ||
el.src == 'https://scdn.cxense.com/cx.js' ||
el.src == 'https://www.googletagservices.com/tag/js/gpt.js'
) {
var newEl = document.createElement('script');
newEl.onerror = el.onerror;
newEl.onload = el.onload;
return newEl;
}
return el;
}
(function(appendChild) {
window.document.body.appendChild = function(el) {
appendChild.call(this, maybeReplaceElement(el));
};
})(window.document.body.appendChild);
(function(insertBefore) {
window.Element.prototype.insertBefore = function(el, refEl) {
insertBefore.call(this, maybeReplaceElement(el), refEl);
};
})(window.Element.prototype.insertBefore);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment