GameDownloader *OLD*

Finds the game URL and adds a download link in the "QuickLinks"

当前为 2016-04-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           GameDownloader *OLD*
// @namespace      http://www.kilandor.com/
// @description    Finds the game URL and adds a download link in the "QuickLinks"
// @include        http://*.kongregate.com/games/*
// @source         http://userscripts-mirror.org/scripts/show/70371
// identifier     http://userscripts-mirror.org/scripts/source/70371.user.js
// @version        0.6
// @date           2010-03-08
// ==/UserScript==

//Only loads this code on the main window
if(window.top == window.self)
{
	GM_setValue("game_download_url", "");
	function add_game_download()
	{
		var gameurl = GM_getValue("game_download_url");
		if(gameurl == "")
		{
			setTimeout(add_game_download, 1000);
			return;
		}
		var gamedownload = document.createElement("li");
		gamedownload.setAttribute("style","background-position:0 -100px;");
		gamedownload.innerHTML='&nbsp;<a href="'+gameurl+'">Download Game</a>';
		var quicklinks = document.getElementById('quicklinks');
		quicklinks.appendChild(gamedownload);
	}
	//This is used so it can keep running tryign to add the button, till the iframe is loaded
	//and the URL is stored.
	setTimeout(add_game_download, 1000);
}
else
{
	function URLDecode(psEncodeString)
	{
		// Create a regular expression to search all +s in the string
		var lsRegExp = /\+/g;
		// Return the decoded string
		return unescape(String(psEncodeString).replace(lsRegExp, " "));
	}
	var gamevars;
	//this code is only executed in the iframe where the game is loaded
	//it stores the url into a GreaseMonkey Value, which is the only clean way to access it
	//due to cross site scripting issues(the iframe is loading a subdomain of kongregate)
	var gamediv = document.getElementById('gamediv');
	var gameparams = gamediv.getElementsByTagName('param');
	for (var i = 0; i < gameparams.length; i++)
	{
		if (gameparams[i].getAttribute('name') == 'flashvars')
		{
			gamevars = gameparams[i].getAttribute('value');
		}
	} 
	string = URLDecode(gamevars);
	var gameurldata = string.match(/http:\/\/chat.kongregate.com\/gamez\/([0-9]+)\/([0-9]+)\/live\/(.[^.]+)\.swf/i);
	if(gameurldata == null)
	{
		var gameurl = gamediv.getAttribute('data');
	}
	else
	{
		var gameurl = gameurldata[0];
	}
	GM_setValue("game_download_url", gameurl);
}