Hide 9GAGGER

Hides all anonymous (9GAGGER) posts

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Hide 9GAGGER
// @name:en      Hide 9GAGGER
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Hides all anonymous (9GAGGER) posts
// @description:en  Hides all anonymous (9GAGGER) posts
// @author       You
// @match        https://9gag.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=9gag.com
// @license MIT
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

(function(win, _) {
    'use strict';
    _.parse = win.JSON.parse;
    Object.defineProperty(win.JSON, 'parse', {
        get() {
            return function(){
                let json = _.parse(...arguments);
                if ('data' in Object(json) && 'posts' in Object(json.data)){
                    json.data.posts = json.data.posts.filter(e=>{
                        if (e.creator) return true;
                        //console.log(e);
                        fetch("https://9gag.com/report", {
                            "body": `{"type":8,"entryId":"${e.id}"}`,
                            "method": "POST",
                            "mode": "cors",
                            "credentials": "include"
                        });
                        return false;
                    });
                }
                return json;
            };
        },
        set() {}
    });
})(unsafeWindow, {});