Hard Drop Forum Tweaks

Some tweaks on the Hard Drop Tetris forum

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

// ==UserScript==
// @name           Hard Drop Forum Tweaks
// @description    Some tweaks on the Hard Drop Tetris forum
// @include        http://harddrop.com/*
// @version 0.0.1.20140527053932
// @namespace https://gf.qytechs.cn/users/2233
// ==/UserScript==

var wnd = window;
var doc = wnd.document;
var loc = location;
var href = loc.href;

if(/^http:\/\/harddrop\.com\//.test(href))
{
    if(typeof users_to_hide == 'undefined')
    {
        var users_to_hide = ['USER_ID_1', 'USER_ID_2']; // add as many annoying users as you want
    }
    var len_hide = users_to_hide.length;
    if(/forums/.test(href))
    {
        if(/showtopic/.test(href)) // on a forum thread page
        {
            // hide forum posts from annyoing users
            var tables = doc.getElementsByClassName('ipbtable'), len = tables.length;
            for(var i=0; i<len; i++)
            {
                try
                {
                    for(var j=0; j<len_hide; j++)
                    {
                        if(users_to_hide.indexOf(tables[i].getElementsByTagName('TD')[0].getElementsByTagName('SPAN')[0].children[0].innerHTML)!=-1)
                        {
                            tables[i].style.cssText='display: none !important';
                        }
                    }
                }
                catch(err) {}
            }

            // hide user images, because some images are not comfortable to see
            var imgs = doc.getElementsByClassName('pic1');
            for(var i=imgs.length-1; i>=0; i--) { imgs[i].style.display = 'none'; }
        }
        else // on the forum main page
        {
            // add shoutbox, so that a user can chat with others on the current page
            var sbframe = doc.createElement('IFRAME');
            sbframe.id = 'my_sbframe';
            sbframe.src = 'http://harddrop.com/file/shout/shout.php';
            sbframe.width = 300;
            sbframe.height = 480;
            doc.getElementById('fo_rtopics').appendChild(sbframe)

            // embed the live stream swf if it is live
            GM_xmlhttpRequest({
                method: 'GET',
                url: 'https://api.twitch.tv/kraken/streams/harddrop',
                synchronous: false,
                onload: function(response) {
                    if(JSON.parse(response.responseText).stream != null) { // is live
                        doc.getElementById('fo_rtopics').innerHTML += '<object flashvars="hostname=www.twitch.tv&channel=harddrop&auto_play=false&start_volume=25" type="application/x-shockwave-flash" allowfullscreen="true" allownetworking="true" movie="http://www.twitch.tv/widgets/live_embed_player.swf" allowscriptaccess="always" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=harddrop" width="640" height="480"</object>';
                    }
                }
            });
        }
    }
    else if(/shout/.test(href)) // hide annoying users in the shoutbox
    {
        if(doc.getElementById('ShoutCloud-Container')==null) { throw 'exit'; }
        setTimeout("document.getElementsByName('ShoutCloud-Msg')[0].disabled=false; document.getElementsByName('ShoutCloud-Msg')[0].value=''",3000);
        doc.getElementsByName('ShoutCloud-Msg')[0].onblur = function(){ setTimeout("document.getElementsByName('ShoutCloud-Msg')[0].value=''",0); };
        addEventListener("DOMNodeInserted", function(){ var chats = doc.getElementsByClassName('shout-msg'); var len = chats.length; for(var i=0; i<len; i++) { for(var j=0; j<len_hide; j++) { if(users_to_hide.indexOf(chats[i].children[0].id)!=-1) { chats[i].style.display = 'none'; break } } } }, false); // or DOMSubtreeModified
    }

    throw 'exit'
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址