Greasy Fork

Greasy Fork is available in English.

Block Douban User Status

Block Douban User's Status (reposts excluded)

当前为 2018-01-13 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Block Douban User Status
// @namespace    Zcc
// @version      0.1
// @description  Block Douban User's Status (reposts excluded)
// @author       Zcc
// @match        *://www.douban.com/*
// @match        *://www.douban.com/people/*
// @copyright    2017+, Zcc
// ==/UserScript==

// window.onload = function () {
    // block
    var block_list = JSON.parse(localStorage.getItem('douban_block_list')) || [],
        r_block = new RegExp(block_list.join('|'));
    // console.log("block_list", block_list);
    // console.log("r_block", r_block);
    $(".status-wrapper, .status-wrapper > .reshared_by").each(function(index, wrapper){
        if (!block_list.length) { return false; }
        if (wrapper.dataset.uid.match(r_block)) {   // block the original posts
            // $(wrapper).find('.status-item').hide();  // hide()非法调用
            wrapper.parentNode.removeChild(wrapper);
        }
        // block the reposts
    });
    
    if(window.location.pathname !== "/"){
        // add user to block list
        var listEle = $('.more-opt .user-group-list');
        if (!listEle.length) { return false; }
        // let matches = $('#profile img').attr('src').match(/ul(\d+)/), usrid;
        // if (!matches || matches.length < 2) return false;
        // usrid = matches[1];
        var usrid = people_info.id;
        if (block_list.filter(function (num) {
                return num == usrid;
            }).length) {    // already blocked
            listEle.prepend('<li><a href="javascript:;" class="cancel-block">取消屏蔽</a></li>');
        } else {
            listEle.prepend($('<li><a href="javascript:;" class="block-status">屏蔽广播</a></li>'));
        }
        listEle.delegate('.cancel-block', 'click', function () {
            block_list = block_list.filter(function (num) {
                return usrid != num;
            });
            localStorage.setItem('douban_block_list', JSON.stringify(block_list));
            $(this).removeClass('cancel-block').addClass('block-status').text('屏蔽广播');
        })
        .delegate('.block-status', 'click', function () {
            block_list.push(parseInt(usrid, 10));
            localStorage.setItem('douban_block_list', JSON.stringify(block_list));
            $(this).removeClass('block-status').addClass('cancel-block').text('取消屏蔽');
        });
    }
// };