Playblink Ignore Button

Puts an ignore button on users' profile pages

当前为 2014-06-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name       Playblink Ignore Button
// @namespace  
// @version    0.1.1
// @description  Puts an ignore button on users' profile pages
// @match      http://www.playblink.com/profile/*
// @copyright  2014+, Arpione
// ==/UserScript==

var wrap = document.getElementsByClassName("wrap")[1];

if((wrap.children[0].children.length > 0) && (wrap.children[0].children[0].textContent == "Send me a message")){
    
    var style = document.createElement("style");
    style.setAttribute("type", "text/css");
    style.innerHTML = ".red {" +
        "color: #eeeeee;" +
        "border: solid 1px #A40000;" +
        "background: #CC0000;" +
        "background: -webkit-gradient(linear, left top, left bottom, from(#EE0000), to(#A60000));" +
        "background: -moz-linear-gradient(top,  #EE0000,  #A60000);" +
        "filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#EE0000', endColorstr='#A60000');" +
    "}" +
    ".red:hover {" +
        "background: #AC0000;" +
        "background: -webkit-gradient(linear, left top, left bottom, from(#CC0000), to(#8E0000));" +
        "background: -moz-linear-gradient(top,  #CC0000,  #8E0000);" +
        "filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#CC0000', endColorstr='#8E0000');" +
    "}" +
    ".red:active {" +
        "color: #C3C3C3;" +
        "background: #CC0000;" +
        "background: -webkit-gradient(linear, left top, left bottom, from(#A60000), to(#EE0000));" +
        "background: -moz-linear-gradient(top,  #A60000,  #EE0000);" +
        "filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#A60000', endColorstr='#EE0000');" +
    "}";
    wrap.children[0].appendChild(style);
    
    var button = document.createElement("div");
    var label = document.createTextNode("Ignore");
    
    button.appendChild(label);
    button.setAttribute("class", "button red");
    button.setAttribute("style", "float:right;vertical-align:bottom;margin-right:10px;");
    
    button.onclick = function (){
        var username = wrap.children[0].innerHTML.split(' ')[0];
        var confirmed = window.confirm("Are you sure you want to ignore " + username + "?");
        if(confirmed){
            $.get("/?do=shout&act=ignore&username=" + username, function (res) {
                if (res == "OK") {
                    document.location = "/profile/" + username;
                }else{
                    window.alert("Failed to add " + username + " to the ignore list:\n\"" + res + "\"");
                }
            });
        }
    }
    
    wrap.children[0].appendChild(button);
}