DomainKiller

zakopuje i ukrywa znaleziska na wykopalisku wykop.pl z wybranych przez uzytkownika domen

2017-07-29 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name DomainKiller
// @version 0.7
// @description zakopuje i ukrywa znaleziska na wykopalisku wykop.pl z wybranych przez uzytkownika domen
// @author llinney małpa outlook.com
// @grant none
// @match http://www.wykop.pl/wykopalisko/*
// @match https://www.wykop.pl/wykopalisko/*
// @namespace http://www.wykop.pl/
// ==/UserScript==

// you can fill hardcoded domains table for preserving settings even after browser storage has been cleared.
// example:
// var hardCodedDomains = ['youtube.pl', 'liveleak.com'];
var hardCodedDomains = [];

var paneVisible = false;

function removeDomainFromArray(ind) {
    console.log(ind);
    var array = JSON.parse(localStorage.getItem("unwantedDomains"));
    var removedIt = array.splice(ind,1);
    console.log(removedIt);
    localStorage.setItem("unwantedDomains", JSON.stringify(array));
}

function createPanel() {
    $('#domainKillerPanel').after('<div id="domainKillerPanelDiv" class="dropdown right notificationsContainer bodyClosable"><div><ul id="domainKillerPanelList" class="menu-list"></ul><div></div>');
        var array = JSON.parse(localStorage.getItem("unwantedDomains"));
        var iter = 0;
        array.forEach(function(domain) {
            var currIt = iter;
            $('#domainKillerPanelList').append('<li class="type-light-warning"><p><a>' + domain + '</a><a id="domainKillerPanelListItem' + iter + '" class="close"><i class="fa fa-times"></i></a></p></li>');
            var name = '#domainKillerPanelListItem' + iter;
            $(name).on( "click", function() {
                removeDomainFromArray(currIt);
            });
            iter++;
        });
}

function togglePanel() {
    if (paneVisible) {
        paneVisible = false;
        $('#domainKillerPanelDiv').hide();
    } else {
        paneVisible = true;
        $('#domainKillerPanelDiv').show();
    }
}

function addSettingsIcon() {
    $('#openNaturalSearch').before('<a id="domainKillerPanel" title="Zakopywane domeny" class="dropdown-show ajax"><i class="fa fa-lock"></i></a>');

    $( "#domainKillerPanel" ).on( "click", function() {
        togglePanel();
    });
}

function addDownIcon(tagLine) {
    var source = $(tagLine)[0].getElementsByClassName('affect')[1].innerHTML.toString();
    $(tagLine).children('.tag.create').eq(2).before("<a href='' class='tag affect create' onclick='var array = JSON.parse(localStorage.getItem(\"unwantedDomains\"));Array.prototype.push.apply(array, [\"" + source + "\"]);localStorage.setItem(\"unwantedDomains\", JSON.stringify(array));'>zakopuj domenę</a>");
}

function downAll() {
    var array = JSON.parse(localStorage.getItem("unwantedDomains"));
    console.log('Zakopywane domeny: ' + array);

    $('.article.clearfix.preview.dC').each(function() {
        var downvote;
        var tagLine = $(this).find('.fix-tagline');
        addDownIcon(tagLine);
        var source = $(tagLine)[0].getElementsByClassName('affect')[1].innerHTML.toString();

        if (shouldDown(source, array)) {
            this.getElementsByClassName('fix-tagline')[0].getElementsByClassName('ajax affect create')[0].click();
            downvote = this.getElementsByClassName('dropdown fix-dropdown bodyClosable');

            if (downvote.length > 0) {
                downvote = downvote[0].getElementsByClassName('ajax');
             downvote[4].click();
             console.log('Zakopano: ' + $(this).find('h2').children().eq(0).attr('href'));
            }
        }
    });
}

$(document).ready(function() {
    if (localStorage.getItem("unwantedDomains") === null) {
        localStorage.setItem("unwantedDomains", JSON.stringify(hardCodedDomains));
    }
    work();
});

function shouldDown(source, array) {

    if(jQuery.inArray(source, array) > -1) {
        return true;
    }

    return false;
}

function work() {
    addSettingsIcon();
    createPanel();
    downAll();
}