Skip to content

Instantly share code, notes, and snippets.

@NZDev0
Created February 2, 2023 19:01
Show Gist options
  • Save NZDev0/778e2a1617bf72f1eb34e7f788806d9c to your computer and use it in GitHub Desktop.
Save NZDev0/778e2a1617bf72f1eb34e7f788806d9c to your computer and use it in GitHub Desktop.
Hide games on homepage of GoG
// ==UserScript==
// @name Hide
// @match https://www.gog.com/en
// @run-at document-end
// @version 1.0
// ==/UserScript==
/*
* Titles must be in quotes, seperated by a comma
* ie "Cyberpunk 2077", "Sleeping Dogs: Definitive Edition"
*/
var list_to_hide = [
"Cyberpunk 2077", "Sleeping Dogs: Definitive Edition", "Timberborn"
];
//Give the page 2.5 seconds to populate due to pages angular coding
setTimeout(()=>{
//various types of page layouts games are displayed with
var doc = document.querySelectorAll('.big-spot__title');
for (var i = 0; i < doc.length; i++) {
var game_title = doc[i].innerHTML.trim();
if(list_to_hide.includes(game_title)){
doc[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
}
}
var doc = document.querySelectorAll('.spot__title');
for (var i = 0; i < doc.length; i++) {
var game_title = doc[i].innerHTML.trim();
if(list_to_hide.includes(game_title)){
console.log('matched')
doc[i].parentNode.parentNode.parentNode.parentNode.parentNode.style.display = "none";
}
}
var doc = document.querySelectorAll('.product-tile__title');
for (var i = 0; i < doc.length; i++) {
var game_title = doc[i].innerHTML.trim();
if(list_to_hide.includes(game_title)){
doc[i].parentNode.parentNode.style.display = "none";
}
}
var doc = document.querySelectorAll('.product-tile--grid');
for (var i = 0; i < doc.length; i++) {
var game_title = doc[i].childNodes[1].childNodes[0].title.trim();
if(list_to_hide.includes(game_title)){
doc[i].parentNode.style.display = "none";
}
}
//reshow CSS since GoG make it hidden for all
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '.glide__slide .big-spot__content { visibility: visible; opacity: 1; }';
document.getElementsByTagName('head')[0].appendChild(style);
},2500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment