// ==UserScript==
// @name PIMPMYGOGv3
// @namespace
http://tampermonkey.net/
// @version 0.3.1
// @description try to take over the world!
// @match
https://www.gog.com/*
// @icon
https://www.google.com/s2/favicons?domain=gog.com // @grant none
// @require
http://code.jquery.com/jquery-3.4.1.min.js // ==/UserScript==
(function() {
if(window.location.href.includes("/ajax/")) return;
'use strict';
function log(msg) { console.log("# PIMPMYGOG|LOG> "+msg+";") }
function debug(msg) { console.log("# PIMPMYGOG|DBG> "+msg+";") }
log("HELLO WORLD");
//==================================================================
let pimpmygog = {
forum_hideForumGames: function() {
let mytext = "[Forum game]";
let links = $(".topic_s a").each(function() {
let link = $(this);
let row = link.closest(".list_row_odd");
let babel = row.find(".babel_h");
if(link.text().startsWith(mytext)) {
row.hide();
}
});
},
forum_highlightLinks: function(mytexts,bg,color) {
let regex = new RegExp( mytexts.join( "|" ), "i");
let links = $(".topic_s a").each(function() {
let link = $(this);
let row = link.closest(".list_row_odd");
let babel = row.find(".babel");
if(regex.test(link.text())) {
babel.css("background",bg);
babel.css("color",color);
babel.css("border-radius","20px");
}
});
},
topbar_clearNotifications: function() {
// angular.element(document.body).injector().get('menuNotificationsRepository').deleteAllNotifications();
let menuTray = $(".menu-tray");
let item = $("<div></div>").addClass("menu-item");
let link = $("<a></a>");
link.attr("href","javascript:angular.element(document.body).injector().get('menuNotificationsRepository').dele teAllNotifications();");
link.text("CN");
link.addClass("menu-link");
menuTray.prepend(item.append(link));
},
store_colorDiscounts: function() {
setInterval(() => {
let tiles = $('[selenium-id="productPriceDiscount"]');
tiles.each(function() {
let colors = [ // 29,49,74,94,100
{color:"#757575",from:0,to:49}, // gray
{color:"#e53935",from:50,to:69}, // red
{color:"#fb8c00",from:70,to:89}, // orange
{color:"#43a047",from:90,to:99}, // green
{color:"#1e88e5",from:100,to:100}, // blue
];
let tile = $(this);
let value = tile.text().replace("%","").replace("-","");
try{
value = parseInt(value);
for(let c in colors) {
let color = colors[c];
if(value <= color.to && value >= color.from) {
tile.css("background",color.color+"").css("color","#000");
break;
}
}
} catch(e) {}
});
},2000);
},
store_filterByPercents: function() {
setInterval(() => {
try {
let hash = window.location.hash.substr(1);
let hashData = hash.split('&').reduce(function (res, item) {
var parts = item.split('=');
res[parts[0]] = parts[1];
return res;
}, {});
let percentsFrom = Number(hashData.percentsFrom);
percentsFrom = percentsFrom && percentsFrom >= 0 ? percentsFrom : 0;
let percentsTo = Number(hashData.percentsTo);
percentsTo = percentsTo && percentsTo >= percentsFrom && percentsTo <= 100 ? percentsTo : 100;
let productTiles = $('product-tile');
productTiles.each(function() {
let productTile = $(this);
let discount = $(this).find('[selenium-id="productPriceDiscount"]');
let discountValue = Number(discount.text().replace("%","").replace("-",""));
let title = $(this).find('[selenium-id="productTitle"]').text().trim();
if(discountValue >= percentsFrom && discountValue <= percentsTo) {
productTile.css("display","");
} else {
productTile.css("display","none");
}
});
} catch(e) {}
},2000);
},
darkTheme: function() {
//$('body').addClass('dark-theme');
$('body').removeClass('light-theme');
$('body').addClass('dark-theme');
//$('body').addClass('light-theme');
}
};
//==================================================================
pimpmygog.forum_hideForumGames();
pimpmygog.forum_highlightLinks(["giveaway","free","gifting"],"darkgreen","white");
pimpmygog.forum_highlightLinks(["removal","removed","removing","delisting","delisted"],"black","white");
pimpmygog.topbar_clearNotifications();
pimpmygog.store_colorDiscounts();
pimpmygog.store_filterByPercents();
pimpmygog.darkTheme();
//==================================================================
log("BYE WORLD");
})();