airellian / Storium hide open games

// ==UserScript==
// @name         Storium hide open games
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  For every game in LFP, creates a button in the upper left corner of the game banner. Click on the button to hide the game. FOREVER!
// @author       airellian
// @match        https://storium.com/games/open*
// @require      http://userscripts-mirror.org/scripts/source/107941.user.js
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

function hideGames() {
    let gamesToHide = GM_SuperValue.get('gamesToHide', []);
    let openGames = $('[game-pid]').filter(function(index) {
        return $.inArray($(this).attr('game-pid'), gamesToHide) > -1;
    });
    openGames.parent().parent().parent().hide();
}

var originalDeleteNode = document.createElement('div');
originalDeleteNode.style = 'position: absolute; padding-top: 10px; top: 0; bottom: 0; left: 0;';
originalDeleteNode.innerHTML = '<div class="fav-button banner-alt-btn tutclick_nope ng-isolate-scope"><button aria-label="Delete" class="fav-button small-btn banner-alt-btn">' +
    '<i class="fa fa-times-circle fa-inverse" style="font-size: 15px"></i></button></div>';

(function() {
    'use strict';

    $('.title-cell > h2').each(function() {
        let deleteNode = originalDeleteNode.cloneNode(true);
        let gamePid = $(this).parent().parent().parent().parent().parent().parent().parent().find('[game-pid]').attr('game-pid');
        let deleteButton = $(deleteNode).children().first().children().first();
        $(deleteButton).hover(function() {
            $(this).fadeTo(1,1);
        },function() {
            $(this).fadeTo(1,0);
        });
        $(deleteButton).fadeTo(1,0);
        $(deleteButton).click(function() {
            let gamesToHide = GM_SuperValue.get('gamesToHide', []);
            gamesToHide.push(gamePid);
            GM_SuperValue.set('gamesToHide', gamesToHide);
            hideGames();
        });

        $(this).before(deleteNode);
    });

    hideGames();
})();