DomainKiller

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

29.07.2017 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
}