Greasy Fork is available in English.

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

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

Ajankohdalta 27.3.2024. Katso uusin versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Kongregate Flash games fixer add-on - default swf player setting
// @version      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, Ruffleor AwayFL?\n\n Note: Typing anything else will be treated like "+return_default_behaviour()+".");
    switch(default_player.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();