Kongregate Flash games fixer add-on - default swf player setting

Sets the Kongregate Flash games fixer's default swf player to whatever you prefer.

Verzia zo dňa 08.06.2024. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Kongregate Flash games fixer add-on - default swf player setting
// @version      3.2
// @author       Matrix4348
// @namespace    https://greasyfork.org/users/4818
// @description  Sets the Kongregate Flash games fixer's default swf player to whatever you prefer.
// @license      MIT
// @match        *://www.kongregate.com/games/*/*
// @match        *://www.kongregate.com/*/games/*/*
// @run-at       document-end
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

function FlashSupport(){
    var np=navigator.plugins, npl=np.length;
    for(var k=0;k<npl;k++){ if((np[k].name=="Shockwave Flash")&(np[k].filename!="ruffle.js")){return true;} }
    return false;
}

function return_default_behaviour(){
    if(FlashSupport()==true){ return "Flash"; }
    else if(navigator.userAgent.search("Windows")>-1){ return "SuperNova"; } // At least while Ruffle is not finished.
    else if(navigator.userAgent.search("Windows")==-1){ return "Ruffle"; } // Because SuperNova only works on Windows.
    else { return "Flash"; }
}

function open_settings(){
    var default_player=prompt("Which swf player must be used by default (when a page loads, not when buttons are clicked on): Flash, SuperNova, Ruffle or AwayFL?\n\n Note: Typing anything else will be treated like "+return_default_behaviour()+".");
    switch((default_player|"null").toLowerCase()) {
        case "null":
            break;
        case "flash":
            GM_setValue("default_swf_player","Flash");
            break;
        case "supernova":
            GM_setValue("default_swf_player","SuperNova");
            break;
        case "ruffle":
            GM_setValue("default_swf_player","Ruffle");
            break;
        case "awayfl":
            GM_setValue("default_swf_player","AwayFL");
            break;
        default:
            GM_setValue("default_swf_player",return_default_behaviour());
    }
    document.getElementById("default swf player setting button").innerHTML="Set default swf player <br> <i>Currently: "+GM_getValue( "default_swf_player", return_default_behaviour() )+"</i>";
}

function create_settings_button(){
    var b=document.createElement("button");
    b.id="default swf player setting button";
    b.innerHTML="Set default swf player <br> <i>Currently: "+GM_getValue( "default_swf_player", return_default_behaviour() )+"</i>";
    b.onclick=open_settings;
    b.style.borderWidth="1px";
    b.style.backgroundColor="grey";
    var h=50,w=150;
    b.style.height=h+"px";
    b.style.width=w+"px";
    b.style.position="relative";
    b.style.top=document.getElementById("maingame").clientHeight*(-1)+"px";
    b.style.left=document.getElementById("maingame").clientWidth*(-1/2)-w*1/2+"px";
    document.getElementById("floating_game_holder").appendChild(b);
}

function main_function(){
    var ql=document.getElementById("quicklinks");
    var is_Flash_game, everything_ready;
    if( document.readyState=="complete" && typeof(active_user)!="undefined" && typeof(activateGame)!="undefined" && typeof(holodeck)!="undefined" && ql!==null ){
        if(typeof(active_user.gameType)!="undefined"){
            if(active_user.gameType()=="flash"){ is_Flash_game=true; } else{ is_Flash_game=false; }
        }
        else{ is_Flash_game=-1; }
        if(typeof(LoadFrame4348)!="undefined"){ everything_ready=true; }
        else{ everything_ready=false; }
    }

    if(is_Flash_game==true&&everything_ready){
        create_settings_button();
        var swf_player=GM_getValue( "default_swf_player", return_default_behaviour() );
        LoadFrame4348(swf_player);
    }
    else if(is_Flash_game!=false){ setTimeout(function(){ main_function(); },1000); }
}

main_function();