Greasy Fork

Greasy Fork is available in English.

dA_ignore

ignores people on dA

当前为 2021-04-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        dA_ignore
// @namespace   dA_ignore
// @author   Dediggefedde
// @description ignores people on dA
// @match     http://*.deviantart.com/*
// @match     https://*.deviantart.com/*
// @require    	http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
// @require  		https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @version     1.5.4
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM.setValue
// @grant       GM.getValue
// @grant        GM.xmlHttpRequest
// ==/UserScript==

/* globals $*/
/* globals DiFi*/

/*
Hide comment:
    "4757159042", //commentid
    "298766207", //devid
    "1" //comment/hide ?
DiFi.pushPost("CommentAttributes", "hide", ["4757159042", "298766207", "1"], function (success, data) {
    console.log(data.response.content);
    //tag-count
});
DiFi.send();

eclipse


www.deviantart.com/_napi/shared_api/comments/hide
{
    "itemid": 298766207,
    "commentid": 4757159042,
    "csrf_token": "ZktacCZRqLRc5PzX.q4d2x4.F9_UD4YFxrV8ewlj4-W5VzfVLZfdTkH5bMO0edRXhTo"
}


Hide description?
DiFi.pushPost("DeviationView","getExtrasHTML",["501848540","",{},{"is_referred":0,"origin":"dynamic_nav_click","is_new_tab":1}],function(success, data){
   console.log(data.response.content.html_col1.split("http://www.deviantart.com/tag/").length);
   //tag-count
});
DiFi.send();

*/

var ignorenames = [];
var settings = {
    hideComments: false,
    hideMessages: true,
    deleteMessages: true,
    hideProfile: true,
    hideDeviations: true,
    submitHideRequest: true,
};

function inIgnoreList(name) { //n array of string
    var rex;
    for (var n of name) {
        if (n == "" || n == null) continue;
        for (var i of ignorenames) {
            if (i[0] == '#') {
                rex = new RegExp(i.substr(1), "i");
                if (rex.test(n.toLowerCase())) {
                    return true;
                }
            } else {
                if (n.toLowerCase() == i.toLowerCase()) return true;
            }
        }
    }
    return false;
}

function pruf() {
    //dynamic browsing, check all 1s.
    setTimeout(pruf, 500);

    //eclipse: a.user-link:not(notignore)
    var bnam = $('a.u:not(notignore),a.user-link:not(notignore),div.tt-a:not(notignore),img.avatar:not(notignore)').attr('notignore', '').filter(function () {
        return inIgnoreList([$(this).text(), $(this).attr("username"), $(this).attr("title")]);
    });

    if (settings.hideDeviations) {
        var thumbs = $("div.tt-a.tt-fh:not(notignore)").attr("notignore", "").filter(function () {
            return inIgnoreList([$(this).attr("username")]);
        });
        thumbs.remove();

        thumbs=$("section[data-hook=\"deviation_std_thumb\"]:not(notignore)").attr("notignore", "").filter((id,dl)=>{
            var el=$(dl).find("a[data-hook=\"deviation_link\"]");
            if(el.length>0)el=el.attr("href");
            else return false;
            el=el.match(/deviantart.com\/(.*?)\//);
            if(!el || el.length==1)return false;
            return inIgnoreList([el[1]]);
        });
        thumbs.remove();
    }

    if (settings.hideProfile && $("#da_unignore_but").length == 0 && (bnam.parents('div.catbar').length > 0 || bnam.parents("div._3HAOe").length > 0)) { // && bnam.parents('div.catbar').length > 0 && $("#da_unignore_but").length==0
        var replaceSite = '<div align=center><img src="http://fc01.deviantart.net/fs46/f/2009/196/d/4/d49e01f2265f3024db7194a3622a415f.png" alt="user blocked" /><h1>You blocked this user!</h1></div>';
        $('#gmi-GPage').html(replaceSite);
        $('div.Nvj6n').html(replaceSite); //eclipse
        $("#da_ignore_but").remove();

        if ($("div.gmbutton2town.moarbuttons").length == 0) {
            $("div.catbar").append($('<div class="gmbutton2town moarbuttons">'));
        }
        var al = $("div.gmbutton2town.moarbuttons");
        var clicker = function () {
            var foundindex = ignorenames.indexOf($(this).attr("userid"));
            ignorenames.splice(foundindex, 1);
            setTimeout(() => {
                GM.setValue('blocklist', [...new Set(ignorenames)].join("\n"));
                location.reload();
            }, 0);
        };
        var unignoreBut = $('<a id="da_unignore_but" class="devwatch gmbutton2 gmbutton2qn2r" style="min-width:auto;" title="remove from your ignore-list" href="#"><i class="icon i27"></i><span>UnIgnore</span><b></b></a>').click(clicker);
        var tarn = $(".user-link._2diFW._2_8l-");
        if (tarn.length == 0) {
            tarn = $("#gmi-Gruser").attr("gmi-name").toLowerCase();
        } else {
            tarn = tarn.data("username").toLowerCase();
        }
        unignoreBut.attr("userid", tarn); //eclipse
        al.prepend(unignoreBut);
        al = $("nav.cUIp3"); //eclipse
        al.append(unignoreBut); //eclipse
        al.find("#da_unignore_but").css("background-image", "linear-gradient(242deg,#f00,#ddef31)"); //eclipse
        al.find("#da_unignore_but").addClass("ucOYB _1jsZj"); //eclipse
        return;
    }
    if (bnam.length == 0) return;

    if (settings.deleteMessages) { //&& bnam.parents('div.mcbox') .length > 0
        if (bnam.parents('div.ch-ctrl').length > 0) bnam.parents('div.ch-ctrl').find('span.mcx').click();
        if (bnam.closest("div.Ijp9_").length > 0) bnam.closest("div.Ijp9_").find('button[aria-label="Remove"]').click(); //
    } else
    if (bnam.filter("img.avatar").closest("div.grf-deviants").length > 0) {
        bnam.filter("img.avatar").closest("span.f").remove();
        bnam.filter("img.avatar").closest("div.grf-deviants").remove();
    }
    if (settings.hideDeviations) {
        bnam.parents("span.thumb").remove();
        bnam.parents("div.sVdfP").parent().remove();
    }
    if (bnam.filter("img.avatar").closest('a').length > 0) {
        bnam.filter("img.avatar").closest("a").remove();
    }
    if (settings.hideMessages) {
        bnam.parents('div.mcbox').first().remove();
        bnam.parents("div.Ijp9_").remove(); //eclipse
    }
    if (settings.submitHideRequest) {
        //eclipse
        var dUrl = $('meta[property="og:url"]').attr('content');
        var deviationID = /(\d+)$/.exec(dUrl); //$("div.dev-page-view").attr("gmi-deviationid");
        if(deviationID!=null)deviationID=deviationID[1];
        else{
            // mode = 4; //not deviation, then profile
            deviationID = $("div._79lMq._115pF a.user-link").data("userid");
        }
        var token = $("input[name=validate_token]").val();
        var els=bnam.closest("div[data-commentid]");//bnam.parent().find("a._1CHtu");
        els.not(".ccomment-hidden").addClass("ccomment-hidden").each((i, el) => {
            var dat = {
                "itemid": deviationID,
                "commentid": $(el).attr("data-commentid"),///\d+$/.exec(el.getAttribute("href"))[0],
                "csrf_token": token.toString()
            };
            GM.xmlHttpRequest({
                method: "POST",
                url: "https://www.deviantart.com/_napi/shared_api/comments/hide",
                headers: {
                    "accept": 'application/json, text/plain, */*',
                    "content-type": 'application/json;charset=UTF-8'
                },
                dataType: 'json',
                data: JSON.stringify(dat),
                onerror: function (response) {
                    console.log("error:",response);
                },
                onload: async function (response) {
                    console.log("response",response);
                }
            });
        });

        /*
        //oldDa:
        var cContainer = bnam.closest('div.ccomment').not(".ccomment-hidden");
        var mode = 1; //1: deviation/journal, 4 profile
        // deviationID = $("div.dev-page-view").attr("gmi-deviationid");
        if (deviationID == null) {
            mode = 4; //not deviation, then profile
            deviationID = $("#gmi-Gruser").attr("gmi-id");
        }
        cContainer.each((i, el) => {
            var commentID = el.getAttribute("gmi-commentid");
            DiFi.pushPost("CommentAttributes", "hide", [commentID, deviationID, mode], function (success, data) {
                console.log(data.response.content);
            });
        });
        cContainer.addClass("ccomment-hidden");
        if(cContainer.length > 0){
            DiFi.send();
        }
        */
    }
    if (settings.hideComments) {
        var cContainer = bnam.closest('div.ccomment');
        cContainer.remove();
        bnam.closest('div').remove(); //eclipse
    }
    if (settings.hideComments && bnam.parents('div.deviation-full-minipage').length > 0) {
        bnam.parents('div.deviation-full-minipage').prev("div.deviation-full-container").remove();
        bnam.parents('div.deviation-full-minipage').remove();
    }

}

if ($("div.catbar").length > 0 || $("nav.cUIp3").length > 0) {
    if ($("#da_ignore_but").length == 0) {
        if ($("div.gmbutton2town.moarbuttons").length == 0) {
            $("div.catbar").append($('<div class="gmbutton2town moarbuttons">'));
        }
        var al = $("div.gmbutton2town.moarbuttons");
        var ignoreBut = $('<a id="da_ignore_but" class="devwatch gmbutton2 gmbutton2qn2r" style="min-width:0;" title="Add to your ignore-list" href="#"><i class="icon i27"></i><span>Ignore</span><b></b></a>').click(
            function () {
                if ($("#deviant a.u").length > 0) {
                    ignorenames.push($("#deviant a.u").html().toLowerCase());
                } else {
                    ignorenames.push($("h1.AEPha a.user-link").text().toLowerCase());
                }

                setTimeout(() => {
                    GM.setValue('blocklist', [...new Set(ignorenames)].join("\n")); //save unique array
                }, 0);
            });
        al.prepend(ignoreBut);
        al = $("nav.cUIp3");
        al.append(ignoreBut); //eclipse
        al.find("#da_ignore_but").css("background-image", "linear-gradient(242deg,#f00,#ddef31)"); //eclipse
        al.find("#da_ignore_but").addClass("ucOYB _1jsZj"); //eclipse
    }
}
if (location.href.indexOf('https://www.deviantart.com/settings') == 0) {
    var ignoremenu = $('<li><a href="#">Ignore User</a></li>');
    $('#settings_public').parent().after(ignoremenu);
    ignoremenu.find('a').click(function () {
        $('a.active').removeClass('active');
        $(this).addClass('active');
        $('div.settings_form').html('' +
            '<div class="fooview ch">' +
            '<div class="fooview-inner">' +
            '<h3>Ignore Users</h3>' +
            '<span>Separate usernames by linebreaks!</span>' +
            '<fieldset style="border:none;padding:0;">' +
            '<textarea cols="70" rows="4" class="itext_uplifted" id="da_ignore_textarea">' + ignorenames.join('\n') + '</textarea>' +
            '</fieldset>' +
            '<div class=" buttons ch hh " id="submit">' +
            '<div style="text-align:right" class="rr">' +
            '<a class="smbutton smbutton-green" href="javascript:void(0)"><span id="da_ignore_saveblocklist">Save</span></a>' +
            '</div></div></div></div>' +
            '' +
            '<div class="fooview ch">' +
            '<div class="fooview-inner">' +
            '<h3>Behavior</h3>' +
            '<div class="altaltview altaltview-wider">' +
            '<div class="row">' +
            '<input ' + (settings.hideComments ? 'checked="checked"' : '') + ' type="checkbox" value="1" id="da_ignore_hideComments" class="icheckbox">' +
            '<label for="da_ignore_hideComments" class="l">Hide Comments</label>' +
            '<br><small>This will automatically <strong>hide</strong> comments and replies made by a ignored user. This affects all Submissions. Other People can still see comments hidden like this.</small>' +
            '</div>' +
            '<div class="browse-sitback row">' +
            '<input ' + (settings.hideMessages ? 'checked="checked"' : '') + ' type="radio" value="1" id="da_ignore_hideMessages" name="da_ignore_message" class="icheckbox">' +
            '<label for="da_ignore_hideMessages" class="l">Hide Messages</label>' +
            '<br><small>This will automatically <strong>hide</strong> Replies and Comments given to you by ignored users. Hidden Comments are still existent and won\'t get removed.</small>' +
            '</div>' +
            '<div class="browse-sitback row">' +
            '<input ' + (settings.deleteMessages ? 'checked="checked"' : '') + ' type="radio" value="1" id="da_ignore_deleteMessages" name="da_ignore_message" class="icheckbox">' +
            '<label for="da_ignore_deleteMessages" class="l">Delete Messages</label>' +
            '<br><small>This will automatically <strong>delete</strong> Replies and Comments given to you by ignored users.</small>' +
            '</div>' +
            '<div class="browse-sitback row">' +
            '<input ' + (settings.hideProfile ? 'checked="checked"' : '') + ' type="checkbox" value="1" id="da_ignore_hideprofile" class="icheckbox">' +
            '<label for="da_ignore_hideprofile" class="l">Hide Profile</label>' +
            '<br><small>This will automatically hide ignored user\'s profile-page. You can still visit them, but instead of their profile-content, there will be a notification.</small>' +
            '</div>' +
            '<div class="browse-sitback row">' +
            '<input ' + (settings.hideDeviations ? 'checked="checked"' : '') + ' type="checkbox" value="1" id="da_ignore_hideDeviations" class="icheckbox">' +
            '<label for="da_ignore_hideDeviations" class="l">Hide Deviations</label>' +
            '<br><small>Hide all submissions from a user that are displayed on deviantart\'s front-pages.</small>' +
            '</div>' +
            '<div class="browse-sitback row">' +
            '<input ' + (settings.submitHideRequest ? 'checked="checked"' : '') + ' type="checkbox" value="1" id="da_ignore_submitHideRquest" class="icheckbox">' +
            '<label for="da_ignore_submitHideRquest" class="l" title="Requests comments to be hidden for everyone. Only works on your profile/deviations!">Hide comments for public (?)</label>' +
            '<br><small>Hide all submissions from a user that are displayed on deviantart\'s front-pages.</small>' +
            '</div>' +
            '<div class=" buttons ch hh " id="submit">' +
            '<div style="text-align:right" class="rr">' +
            '<a class="smbutton smbutton-green" href="javascript:void(0)"><span id="da_ignore_savesettings">Save</span></a>' +
            '</div></div></div></div></div>');
        $('#da_ignore_saveblocklist').click(() => {
            ignorenames = $('#da_ignore_textarea').val().toLowerCase().split('\n');
            setTimeout(() => {
                GM.setValue('blocklist', [...new Set(ignorenames)].join("\n"));
            }, 0);
            alert('List saved!');
        });
        $('#da_ignore_savesettings').click(() => {
            settings.hideComments = $('#da_ignore_hideComments').prop('checked');
            settings.hideMessages = $('#da_ignore_hideMessages').prop('checked');
            settings.deleteMessages = $('#da_ignore_deleteMessages').prop('checked');
            settings.hideProfile = $('#da_ignore_hideprofile').prop('checked');
            settings.hideDeviations = $('#da_ignore_hideDeviations').prop('checked');
            settings.submitHideRequest = $('#da_ignore_submitHideRquest').prop('checked');
            setTimeout(() => {
                GM.setValue('settings', JSON.stringify(settings));
            }, 0);
            alert('List saved!');
        });
    });
}
async function loadsettings() {
    var Zignorenames = await GM.getValue('blocklist', null);
    if (Zignorenames != null) ignorenames = Zignorenames.split('\n');
    var Zsettings = await GM.getValue('settings', null);
    if (Zsettings != null) settings = $.parseJSON(Zsettings);

    if (settings.hideComments == null) settings.hideComments = true;
    if (settings.hideMessages == null) settings.hideMessages = false;
    if (settings.deleteMessages == null) settings.deleteMessages = true;
    if (settings.hideProfile == null) settings.hideProfile = true;
    if (settings.hideDeviations == null) settings.hideDeviations = true;
}

var prom = loadsettings();
prom.then(pruf);