Kongregate Flash games fixer

Play Flash games on Kongregate with Flash again!

目前為 2022-01-10 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Kongregate Flash games fixer
// @version      1.0
// @description  Play Flash games on Kongregate with Flash again!
// @author       Matrix4348
// @license      MIT
// @match        *://*.konggames.com/games/*/*/frame/*
// @grant        none
// @namespace https://greasyfork.org/users/4818
// ==/UserScript==

// The script must be restrained to the Flash iframes (the URL for the html games iframes look a bit different, but there may be some exceptions).
if ((document.URL.search("/frame/")>-1)&(document.body.innerHTML.search("kong_flash_variables")>-1)){
    // First, we need to extract the link to the swf (the game file).
    var file_url0, file_url, file_url_base;
    var scripts=document.getElementsByTagName("script");
    for(var i=0; i<scripts.length;i++) {var script_text=scripts[i].text;
                                        var url_text;
                                        if(script_text.indexOf("game_swf")!== -1) {
                                            url_text=String(script_text.match(/game_swf\"\:\"(.*?)\"\,\"game_url/g));
                                            file_url0="https://"+decodeURIComponent(url_text.substring(17,(url_text.length/2)-11));
                                            break;
                                        }
                                        else if(script_text.indexOf("swfurl")!== -1) {
                                            url_text=String(script_text.match(/swfurl\"\:\"(.*?)\"\,\"flashvars/g));
                                            file_url0=decodeURI(url_text.substring(9,url_text.length-12));
                                            break;
                                        };
                                       };
    file_url=file_url0.substring(file_url0.search("//"),file_url0.length-1);
    file_url_base="http:"+file_url.substring(0,file_url.search("/live/")+6);

    // Now, let's write in the page's HTML.
    var a=document.createElement("script");
    a.id="Fixing area";
    // IMPORTANT: Apparently, something in the code knows the correct flashvars, this is why I will not input any.
    a.innerHTML=
`//<![CDATA[

gameLoader = {
   loadGame: function(urlOptions) {
      var swf_location = "`+file_url+`";
      var swfobject_flash_vars = {};
      if(typeof(kong_flash_variables) == "object"){
         for(var k in kong_flash_variables){
            swfobject_flash_vars[k] = encodeURIComponent(kong_flash_variables[k]);
         }
      }
   swfobject.embedSWF(swf_location, "gamediv","100%","100%","6","/flash/expressInstall.swf",swfobject_flash_vars,{"bgcolor":"#000000","allownetworking":"all","allowscriptaccess":"always","base":"`+file_url_base+`"},{});
   }
}

function activateGameWithFlash(urlOptions) {
   if (!urlOptions) {
      urlOptions = '';
   }
   gameLoader.loadGame(urlOptions);
   document.fire('game:activated');
};
activateGameWithFlash();

//]]>`;
    document.body.appendChild(a);
}