Skip to content

Instantly share code, notes, and snippets.

@BonsaiDen
Last active February 28, 2017 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BonsaiDen/63bf36f7ab493469fda4c5561d1ca179 to your computer and use it in GitHub Desktop.
Save BonsaiDen/63bf36f7ab493469fda4c5561d1ca179 to your computer and use it in GitHub Desktop.
Stuff
// ==UserScript==
// @name AntiNintendoSpoiler
// @namespace foobar
// @include https://www.youtube.com/*
// @version 1
// @grant none
// ==/UserScript==
var originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
originalOpen.apply(this, arguments);
if (arguments[1].indexOf('youtube.com') !== -1) {
this.addEventListener('readystatechange', (function() {
if (this.readyState === 4) {
setTimeout(function() {
hide();
}, 0);
setTimeout(function() {
hide();
}, 50);
}
}).bind(this), false);
}
};
var users = {
GameXplain: 'UCfAPTv1LgeEWevG8X_6PUOQ',
Nintendo: 'UCGIY_O-8vW4rfX98KlMkvRg',
'Game Informer': 'UCK-65DO2oOxxMwphl2tYtcw',
Eurogamer: 'UCciKycgzURdymx-GRSY2_dA',
Polygon: 'UCuVxaQDraOja6xKidcmoufA',
'Nintendo Deutschland': 'UCic48jpZWaG_kQ0sj9pTS1w',
'Hylian Hero': 'UCOUfuh4-qUufHhbGxCiNy1A',
'IM Switch': 'UC6gMkl0numkycRMb7KRrR4Q',
FamilyGames: 'UCgfc8GB-s6h6eDyXRqRo2aQ',
Dystify: 'UCpkBAobv7YgNQ7pPFYp_Ycw',
NintendoHQ: 'UC5fMJlpZ5kEQVXa8XrsNPgQ',
'Commonwealth Realm': 'UCOkE7SxzwKUII9CxfggMSIw',
ZeldaMaster: 'UC-ol6cvdiLjBn4FrGgvhdrA',
Domtendo: 'UCXGPGV90SPduyn9LVX9s7Kw',
SwitchForce: 'UC8wucBti_VxVFhUAzOLyMHw',
IGN: 'UCKy1dAqELo0zrOtPkf0eTMw',
GoNintendo: 'UCvQPbLRLHSUWy7km3iaN4ng',
'Easy Allies': 'UCZrxXp1reP8E353rZsB3jaA',
'GameOver Jesse': 'UCU3C2fxkkG2qPiVfxZH_7tw',
GameSpot: 'UCbu2SsF-Or3Rsn3NxqODImw',
'Dante Nintendo Switch World': 'UCRnPfho_erzTmDORFBDY55Q',
Blunty: 'UCppifd6qgT-5akRcNXeL2rw',
'Katie Wilson': 'UCVi7xUv8w1ytXMcsT8MuYBA',
'COGconnected': 'UCrk7jhruZVuLshUNh1qUi4g'
};
var selector = '[data-ytid="' + Object.values(users).join('"], [data-ytid="') + '"]';
var originalLoad;
function hide() {
var nodes = document.querySelectorAll(selector),
exp = /video-list-item|yt-lockup-video|item-section/ig;
console.log('Hiding ', nodes.length, ' videos...');
Array.prototype.slice.call(nodes).forEach(function(e) {
try {
var p = e.parentNode;
while(p && p.nodeName !== 'BODY' && !exp.test(p.classList.toString())) {
p = p.parentNode;
}
if (p && (p.nodeName === 'DIV' || p.nodeName === 'LI')) {
p.querySelectorAll('img')[0].style.opacity = '0';
var desc = p.querySelectorAll('[aria-describedby]')[0];
if (desc) {
desc.innerText = 'Potential Spoilers';
}
}
} catch(e) {
console.log(e);
}
});
if (!originalLoad && window.ytmod.player.endscreen.prototype.load) {
originalLoad = window.ytmod.player.endscreen.prototype.load;
window.ytmod.player.endscreen.prototype.load = function() {
originalLoad.call(this);
var nodes = document.querySelectorAll('.ytp-endscreen-content > a');
Array.prototype.slice.call(nodes).forEach(function(node) {
try {
var authorNode = node.querySelector('.ytp-videowall-still-info-author'),
userName = authorNode.innerText.split('•')[0].trim();
if (users.hasOwnProperty(userName)) {
node.querySelector('.ytp-videowall-still-image').style.opacity = 0;
authorNode.innerText = userName + ' - Potential Spoilers';
}
} catch(e) {
console.log(e);
}
});
};
}
}
hide();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment