My Match Analyzer-New

none

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);