Tetris Friends Tweaks

Some tweaks on Tetris Friends

目前為 2014-05-27 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Tetris Friends Tweaks
// @description    Some tweaks on Tetris Friends
// @include        http://www.tetrisfriends.com/*
// @version 0.0.1.20140527112733
// @namespace https://greasyfork.org/users/2233
// ==/UserScript==

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

if(/^http:\/\/www\.tetrisfriends\.com\//.test(href))
{
    if(/\/leaderboard\/index\.php$/.test(href))
    {
        addEventListener("DOMContentLoaded", function(){ setTimeout('window.leaderboardChange("3", "84", 2, "0", 0, "Sprint")', 100); }, false);
        throw 'exit';
    }
    if(!/\/game\.php\b/.test(href)) { throw 'exit'; }
    wnd.stop();
    if(/Live\/game\.php$/.test(href)) { wnd.stop(); loc.href=href+'?das=117&ar=17&ihs=true&irs=true'; throw 'exit'; }
    addEventListener("DOMContentLoaded", function(){
        var game_swf = '';
        if(/Sprint\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Sprint/OWGameSprint.swf?version=3"; }
        else if(/Live\b/.test(href)) { game_swf = "http://www.tetrisfriends.com/data/games/Live/OWGameTetrisLive.swf?livebust=0165?version=0"; }
        else if(/Ultra\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Ultra/OWGameUltra.swf?version=3"; }
        else if(/Marathon\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Marathon/OWGameMarathon.swf?version=3"; }
        else if(/Mono\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Mono/OWGameColorBlind.swf?version=3"; }
        else if(/Survival\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Survival/OWGameSurvival.swf?version=3"; }
        else if(/NBlox\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/NBlox/nbloxWebsite.swf?version=3"; } // doesn't work
        else if(/Battle2P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Battle2P/OWGameBattle2pMaps.swf?version=0"; }
        else if(/Battle6P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Battle6P/OWGameBattle6P.swf?version=0"; }
        else if(/Rally8P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Rally8P/OWRally8P.swf?version=0"; }
        else if(/Sprint5P\b/.test(href)) { game_swf = "http://tetrisow-a.akamaihd.net/data4_0_0_1/games/Sprint5P/OWGameSprint5p.swf?version=0"; }
        else { game_swf = doc.getElementsByTagName('OBJECT')[0].data; }
        if(game_swf == '') { return; }

        var w = '643', h = '381'; // change the size of swf as you want
        var margin_top = (wnd.innerHeight-h)/2 + 'px';
        doc.body.innerHTML = '<object type="application/x-shockwave-flash" allowscriptaccess="always" data="' + game_swf + '" width="' + w + '" height="' + h + '" id="myflash" style="visibility: visible; display: block; margin-left: auto; margin-right: auto; margin-top:' + margin_top + '">' + '<param name="wmode" value="window">' + doc.getElementsByName("flashvars")[0].outerHTML + '<param name="quality" value="low">' + '</object>';
        for(var i=doc.styleSheets.length-1; i>=0; i--){ doc.styleSheets[i].disabled=true; }
        ////for(var i=0; i<3; i++) { // only needed when the <OBJECT> id is 'contentFlash'
            ////try {
                ////setTimeout(function() {
                    ////doc.getElementsByTagName('OBJECT')[0].style.cssText = 'visibility: visible; margin-top: 140px; margin-left: 280px;'
                    ////doc.getElementsByTagName('OBJECT')[0].as3_prerollDone()
                ////}, 1000)
            ////} catch(e) {}
        ////}

        // buggy...
        //doc.getElementsByTagName('OBJECT')[0].onkeydown = function(evt){ alert('onkeydown'); if(evt.keyCode==73) { evt.preventDefault(); doc.getElementsByTagName("OBJECT")[0].as3_tetrisGameRestart(); } }
        //doc.getElementsByTagName('OBJECT')[0].addEventListener('keydown', function(evt){ alert('keydown'); if(evt.keyCode==73) { evt.preventDefault(); doc.getElementsByTagName("OBJECT")[0].as3_tetrisGameRestart(); } }, false)

        // not yet finished...
        //if(/Live\b/.test(href)) { // if one can't connect to arena after a predefined time, reload the page.
        //}
    }, false)
    throw 'exit';
}