Remove chuanqi

从战旗中移除SB传奇

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Remove chuanqi
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  从战旗中移除SB传奇
// @author       You
// @match        https://greasyfork.org/en/scripts/13404-ac-%E4%BB%8Egoogle-baidu-bing%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E4%B8%AD%E5%B1%8F%E8%94%BD%E5%8D%A1%E9%A5%AD%E6%95%99%E7%A8%8B
// @include /^https?\:\/\/www.zhanqi.tv
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

})();

var blockList = [];

function addToList(id){
    if(blockList.indexOf(id) == -1){
        blockList.push(id);
    }
}

function exists(id){
    return blockList.indexOf(id) != -1;
}

function saveList(){
    var str = JSON.stringify(blockList);
    $.cookie("bls",str);
}

function loadList(){
    var str = $.cookie("bls");
    if(str){
        blockList = JSON.parse(str);
        console.info("load list " + blockList.length);
    }
}

loadList();

mo = new MutationObserver(function(allmutations) {
    //$('li  span:contains("传奇")').closest('li').remove();
    $.each(allmutations, function( index, record ) {
        $.each(record.addedNodes, function(ind, nd){
            if(nd.localName === "li")      {
                var tmp = $(nd);
                var id =tmp.data('room-id');
                var name = tmp.find("span.name").text();
                if(exists(id)){
                    console.info("block ["+id+"] " + name);
                    tmp.remove();
                }else{
                    if(tmp.find('span:contains("传奇")').length > 0){
                        tmp.remove();
                        console.info("block " + name);
                    }
                }


                // register event
                var spanViews = tmp.find("span.views");
                spanViews.click(function(e){
                    e.preventDefault();
                    e.stopImmediatePropagation();
                    console.info("add to block "+id);
                    addToList(id);
                    saveList();
                    tmp.remove();
                });

                spanViews.hover(
                    function(){
                        var txt =tmp.find("span.views span.dv").text();
                        tmp.data('v-text',txt);
                        tmp.find("span.views span.dv").text("JB88");
                    },
                    function(){
                        var txt = tmp.data('v-text');
                        tmp.find("span.views span.dv").text(txt);
                    });
                spanViews.css("cursor","pointer");
            }
        });
    });
});

var targets = document.body;
mo.observe(targets, {'childList': true,'characterData':true,'subtree': true});