My Match Analyzer-New

none

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           My Match Analyzer-New
// @namespace      *trophymanager.com/matches*
// @include        *trophymanager.com/matches*
// @version        3
// @grant          none
// @description     none
// ==/UserScript==

function installFunc(source) {
/*
  // Check for function input.
  if ('function' == typeof source) {
    // Execute this function with no arguments, by adding parentheses.
    // One set around the function, required for valid syntax, and a
    // second empty set calls the surrounded function.
    source = '(' + source + ')();'
  }
*/
  // Create a script node holding this  source code.
  var script = document.createElement('script');
  script.setAttribute("type", "application/javascript");
  script.textContent = source;

  // Insert the script node into the page, so it will run
  document.body.appendChild(script);
}

/*
Taken from http://www.tomhoppe.com/index.php/2008/03/dynamically-adding-css-through-javascript/
*/
function addCss(cssCode) {
var styleElement = document.createElement("style");
  styleElement.type = "text/css";
  if (styleElement.styleSheet) {
    styleElement.styleSheet.cssText = cssCode;
  } else {
    styleElement.appendChild(document.createTextNode(cssCode));
  }
  document.getElementsByTagName("head")[0].appendChild(styleElement);
}

function loadJS(filename)
{
	var fileref=document.createElement('script');
	fileref.setAttribute("type","text/javascript");
	fileref.setAttribute("src", filename);
	
	document.getElementsByTagName("head")[0].appendChild(fileref);
}

function clickAnalyze()
{
	//get match id
	var mid = document.URL.split(".com/")[1].split("/")[1].split("#")[0].split("?")[0];
	container = document.getElementById("mma_data");
	container.value = JSON.stringify(match_data);
	
	midc = document.getElementById("mma_mid");
	midc.value = JSON.stringify(match_id);
	
	mids = document.getElementById("mma_season");
	mids.value = JSON.stringify($("a[title]").first().html().split(' ')[1])

	if (!end_of_game)
		alert("Wait for match to end")
	else
	{
		myform = document.getElementById("mma_form");
		myform.action = "http://trophyhelptool.com/mma/report.php";
		myform.submit();
	}
}

function clickSave()
{
	//get match id
	var mid = document.URL.split(".com/")[1].split("/")[1].split("#")[0].split("?")[0];
	container = document.getElementById("mma_data");
	container.value = JSON.stringify(match_data);
	
	midc = document.getElementById("mma_mid");
	midc.value = JSON.stringify(match_id);
	
	
	mids = document.getElementById("mma_season");
	mids.value = JSON.stringify($("a[title]").first().html().split(' ')[1])

	if (!end_of_game)
		alert("Wait for match to end")
	else
	{
		myform = document.getElementById("mma_form");
		myform.action = "http://trophyhelptool.com/mma/savereport.php";
		myform.submit();
	}
}

window.addEventListener('load', function (e)
{
	installFunc( clickAnalyze );
	installFunc( clickSave );
	installFunc( addCss );
	installFunc( loadJS );
	
	var fileref=document.createElement('script');
	fileref.setAttribute("type","text/javascript");
	fileref.setAttribute("src", "http://trophyhelptool.com/mma/json2.js");
	
	document.getElementsByTagName("head")[0].appendChild(fileref);
	
	loadJS("http://trophyhelptool.com/mma/json2.js");
	
	addCss(".mma_big { height: 30px; width: 400px; background: url(http://trophyhelptool.herobo.com/mma/scr_back.png); position: fixed; bottom: 0px; left: 10px; z-index: 10;}");
	addCss(".mma_analyze { left: 200px; top: 5px; height: 20px; position: relative; width: 60px; float: left; background: url(http://trophyhelptool.herobo.com/mma/analyze.png); }");
	addCss(".mma_analyze:hover { background: url(http://trophyhelptool.com/mma/analyze_hover.png); cursor: pointer; }");
	addCss(".mma_saverep { left: 220px; top: 5px; height: 20px; position: relative; width: 100px; float: left; background: url(http://trophyhelptool.herobo.com/mma/saverep.png); }");
	addCss(".mma_saverep:hover { background: url(http://trophyhelptool.herobo.com/mma/saverep_hover.png); cursor: pointer; }");

	thisform = document.createElement("form");
	thisform.method = "post";
	thisform.setAttribute("id", "mma_form");
	thisform.setAttribute("target", "_blank");
	
	formdata = document.createElement("input");
	formdata.setAttribute("id", "mma_data");
	formdata.setAttribute("type", "hidden");
	formdata.setAttribute("name", "data");
	
	thisform.appendChild(formdata);
	
	formmid = document.createElement("input");
	formmid.setAttribute("id", "mma_mid");
	formmid.setAttribute("type", "hidden");
	formmid.setAttribute("name", "mid");
	
	thisform.appendChild(formmid);
	
	formseason = document.createElement("input");
	formseason.setAttribute("id", "mma_season");
	formseason.setAttribute("type", "hidden");
	formseason.setAttribute("name", "season");
	
	thisform.appendChild(formseason)
	
	document.body.appendChild(thisform);

	div = document.createElement("div");
	div.setAttribute("class", "mma_big");
	
	div.innerHTML = '<div class="mma_analyze" onclick="clickAnalyze();"></div><div class="mma_saverep" onclick="clickSave();"></div>';
	
	document.body.appendChild(div);
	
}, false);