WebSuckIt!

Ugh, these Webs these Sockets... Nobody need them.

Από την 14/07/2016. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         WebSuckIt!
// @namespace    lainscripts_websuckit
// @version      2.12
// @description  Ugh, these Webs these Sockets... Nobody need them.
// @author       lainverse
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==
(function() {
    'use strict';
    var to_block = [
        '||bgrndi.com^',
        '||brokeloy.com^',
        '||dreadfula.ru^',
        '||et-code.ru^',
        '||gocdn.ru^',
        '||hghit.com^',
        '||kuveres.com^',
        '||lepubs.com^',
        '||mail.ru^',
        '||marketgid.com^',
        '||mxtads.com^',
        '||psma01.com^',
        '||psma02.com^',
        '||psma03.com^',
        '||regpole.com^',
        '||torvind.com^',
        '||trafmag.com^',
        '||xxuhter.ru^'
    ], masks = [];
    to_block.forEach(function(m){
        masks.push(new RegExp(
            m.replace(/([\./*+?()[]{}$])/g, '\\$1')
            .replace(/\^(?!$)/g,'\\.?[^\\w%._-]')
            .replace(/\^$/,'\\.?([^\\w%._-]|$)')
            .replace(/^\|\|/,'^wss?:\\/+([^/.]+\\.)*'),
            'i'));
    });
    var ws = window.WebSocket;
    window.WebSocket = new Proxy(ws, {
        construct: function(e,i) {
            var url = i[0];
            console.log('[WSI] Opening socket on', url, '…');
            var j = masks.length;
            while(j--)
                if (masks[j].test(url)) {
                    console.log("[WSI] Blocked.");
                    return new Proxy({url: url, readyState: ws.OPEN}, {
                        get: function(tgt, nm) {
                            console.log('[WSI] Registered call to property "', nm, '"');
                            try {
                                if (typeof ws.prototype[nm] === 'function') {
                                    if (['close', 'send'].indexOf(nm) > -1)
                                        tgt.readyState = ws.CLOSED;
                                    return function(){};
                                }
                                if (typeof ws.prototype[nm] === 'number') {
                                    return ws[nm];
                                }
                            } catch(e) {}
                            return tgt[nm];
                        }
                    });
                }
            return new e(i[0],i[1]);
        }
    });
})();