OS2.spielerstatistik: Unterschied zwischen den Versionen

Aus Online-Soccer-Wiki
Zur Navigation springen Zur Suche springen
(Geeignet für Greasemonkey 4.0/Firefox 57.0 Quantum, Header, @include-Pattern, Umlaute, GM4-Polyfill)
Zeile 1: Zeile 1:
[[Kategorie:Greasemonkey]]
[[Kategorie:Greasemonkey]]
[[Kategorie:Greasemonkey WE]]
{| style="background-color:white; font-size:11px; float: right; margin:3px 3px 3px 10px; border:1px solid #999; border-color: #8c9a7c; border-collapse:collapse;" width=500 cellpadding=3 cellspacing=0
{| style="background-color:white; font-size:11px; float: right; margin:3px 3px 3px 10px; border:1px solid #999; border-color: #8c9a7c; border-collapse:collapse;" width=500 cellpadding=3 cellspacing=0
| colspan="2" style="padding:0.3em; background-color:#8c9a7c; font-size: 18px; color:#FFFFFF" align=center| '''OS2.spielerstatistik'''
| colspan="2" style="padding:0.3em; background-color:#8c9a7c; font-size: 18px; color:#FFFFFF" align=center| '''OS2.spielerstatistik'''
Zeile 7: Zeile 8:
|- bgcolor="#CCCCCC"
|- bgcolor="#CCCCCC"
| '''Version'''
| '''Version'''
| 0.1
| 0.1 (WebExtensions)
|- bgcolor="#CCCCCC"
|- bgcolor="#CCCCCC"
| '''Autor'''
| '''Autor'''
Zeile 25: Zeile 26:
// @name        OS2.spielerstatistik
// @name        OS2.spielerstatistik
// @namespace    http://os.ongapo.com/
// @namespace    http://os.ongapo.com/
// @version      0.1
// @version      0.1-SLC-WE
// @copyright    2016+
// @copyright    2016+
// @author      Roman Bauer
// @author      Roman Bauer
// @description  Sortierung/Formatierung der Statistikspalten
// @description  Sortierung/Formatierung der Statistikspalten
// @include      http*://os.ongapo.com/showteam.php?*s=3*
// @include      /^https?://(www\.)?(os\.ongapo\.com|online-soccer\.eu|os-zeitungen\.com)/st\.php\?s=[34]&c=\d+$/
// @include      http*://www.os.ongapo.com/showteam.php?*s=3*
// @include      /^https?://(www\.)?(os\.ongapo\.com|online-soccer\.eu|os-zeitungen\.com)/showteam\.php\?s=[34]$/
// @include      http*://online-soccer.eu/showteam.php?*s=3*
// @grant        GM.addStyle
// @include      http*://www.online-soccer.eu/showteam.php?*s=3*
// @require     https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @include      http*://os-zeitungen.com/showteam.php?*s=3*
// @include      http*://www.os-zeitungen.com/showteam.php?*s=3*
// @include      http*://os.ongapo.com/st.php?*s=3*
// @include      http*://www.os.ongapo.com/st.php?*s=3*
// @include      http*://online-soccer.eu/st.php?*s=3*
// @include      http*://www.online-soccer.eu/st.php?*s=3*
// @include      http*://os-zeitungen.com/st.php?*s=3*
// @include      http*://www.os-zeitungen.com/st.php?*s=3*
// @include      http*://os.ongapo.com/showteam.php?*s=4*
// @include      http*://www.os.ongapo.com/showteam.php?*s=4*
// @include      http*://online-soccer.eu/showteam.php?*s=4*
// @include      http*://www.online-soccer.eu/showteam.php?*s=4*
// @include      http*://os-zeitungen.com/showteam.php?*s=4*
// @include      http*://www.os-zeitungen.com/showteam.php?*s=4*
// @include      http*://os.ongapo.com/st.php?*s=4*
// @include      http*://www.os.ongapo.com/st.php?*s=4*
// @include      http*://online-soccer.eu/st.php?*s=4*
// @include     http*://www.online-soccer.eu/st.php?*s=4*
// @include      http*://os-zeitungen.com/st.php?*s=4*
// @include      http*://www.os-zeitungen.com/st.php?*s=4*
// @grant        GM_addStyle
// @grant        GM_addStyle
// ==/UserScript==
// ==/UserScript==
/*global GM_addStyle */


(function () {
(function () {
Zeile 86: Zeile 65:


if (r === 0 || r === (tableClone.rows.length - 1)) {
if (r === 0 || r === (tableClone.rows.length - 1)) {
// Zeile wird weier unten gelöscht
// Zeile wird weiter unten geloescht
} else if (r === 1 || r === (tableClone.rows.length - 2)) {
} else if (r === 1 || r === (tableClone.rows.length - 2)) {


Zeile 120: Zeile 99:
}
}


if (r > 0 && r < (tableClone.rows.length - 1)) {
if ((r > 0) && (r < (tableClone.rows.length - 1))) {
for (c = 3; c < SORT_COLUMNS.length; c++) {
for (c = 3; c < SORT_COLUMNS.length; c++) {
tableClone.rows[r].cells[c].setAttribute("art", SORT_COLUMNS[c]);
tableClone.rows[r].cells[c].setAttribute("art", SORT_COLUMNS[c]);
Zeile 136: Zeile 115:
table.parentNode.replaceChild(tableClone, table);
table.parentNode.replaceChild(tableClone, table);


GM_addStyle('table[id^=team] td[art=LI] div div { margin-left:-8px !important; }');
GM.addStyle('table[id^=team] td[art=LI] div div { margin-left:-8px !important; }');
GM_addStyle('table[id^=team] td[art=LI] { padding-left:10px !important; }');
GM.addStyle('table[id^=team] td[art=LI] { padding-left:10px !important; }');


})();
})();
</pre>
</pre>

Version vom 16. November 2017, 11:43 Uhr

OS2.spielerstatistik
Dateiname os2.spielerstatistik.user.js
Version 0.1 (WebExtensions)
Autor Roman Bauer, FC Cork
Beschreibung
 
Spaltenformatierung und -sortierung bei den Spielerstatistiken
Landesflagge bei den Spielerstatistiken
Letzte Änderung 16.11.2017

Quellcode

// ==UserScript==
// @name         OS2.spielerstatistik
// @namespace    http://os.ongapo.com/
// @version      0.1-SLC-WE
// @copyright    2016+
// @author       Roman Bauer
// @description  Sortierung/Formatierung der Statistikspalten
// @include      /^https?://(www\.)?(os\.ongapo\.com|online-soccer\.eu|os-zeitungen\.com)/st\.php\?s=[34]&c=\d+$/
// @include      /^https?://(www\.)?(os\.ongapo\.com|online-soccer\.eu|os-zeitungen\.com)/showteam\.php\?s=[34]$/
// @grant        GM.addStyle
// @require      https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @grant        GM_addStyle
// ==/UserScript==

(function () {

	'use strict';

	const TOP_COLUMNS = ["","Spiele","Tore","Vorlagen","Score","Gelb","Rot"];
	const SORT_COLUMNS = ["Name","Land","U","LI","LP","IP","FS","LI","LP","IP","FS","LI","LP","IP","FS","LI","LP","IP","FS","LI","LP","IP","FS","LI","LP","IP","FS"];

	var table = document.getElementsByTagName("table")[2], tableClone = table.cloneNode(true), r, row, spieler, baseCell, c, cellSkillschnitt, cellOpti;

	var getSortLink = function (text) {

		return "<a onclick=\"ts_resortTable(this);return false;\" class=\"sortheader\" href=\"#\">" + text +
			"<span span=\"\" <=\"\" class=\"sortarrow\"></span></a>";
	};

	var makeTitleDivRelativToCell = function (cell) {

		var title = TOP_COLUMNS[((cell.cellIndex - 3) / 4) + 1], offset = cell.parentNode.rowIndex === 1 ? -21 : 21;

		cell.innerHTML = "<div style=\"position:relative\">" + "<div style=\"position:absolute; " + "left:0px; top:" + offset +
			"px; width:90px; height:21px\">" + title + "</div></div>" + cell.innerHTML;
	};

	for (r = 0; r < tableClone.rows.length; r++) {

		row = tableClone.rows[r];

		if (r === 0 || r === (tableClone.rows.length - 1)) {
			// Zeile wird weiter unten geloescht
		} else if (r === 1 || r === (tableClone.rows.length - 2)) {

			row.cells[SORT_COLUMNS.indexOf("Land")].colSpan = 1;

			for (c = 0; c < SORT_COLUMNS.length; c++) {
				if (c > 2) {
					row.cells[c].align = "center";
				}
				if (r === 1) {
					row.cells[c].innerHTML = getSortLink(row.cells[c].textContent);
				}
			}

			makeTitleDivRelativToCell(row.cells[3]); // Spiele
			makeTitleDivRelativToCell(row.cells[7]); // Tore
			makeTitleDivRelativToCell(row.cells[11]); // Vorlagen
			makeTitleDivRelativToCell(row.cells[15]); // Score
			makeTitleDivRelativToCell(row.cells[19]); // Gelb
			makeTitleDivRelativToCell(row.cells[23]); // Rot

			if (r === (tableClone.rows.length - 2)) {
				row.className = "sortbottom";
			}

		} else {

			row.cells[SORT_COLUMNS.indexOf("Land")].parentNode.removeChild(row.cells[SORT_COLUMNS.indexOf("Land")]);

			row.cells[SORT_COLUMNS.indexOf("Land")].innerHTML = "<img src=\"images/flaggen/" + row.cells[SORT_COLUMNS.indexOf("Land")].textContent +
				".gif\"\/> " + row.cells[SORT_COLUMNS.indexOf("Land")].innerHTML;

		}

		if ((r > 0) && (r < (tableClone.rows.length - 1))) {
			for (c = 3; c < SORT_COLUMNS.length; c++) {
				tableClone.rows[r].cells[c].setAttribute("art", SORT_COLUMNS[c]);
				tableClone.rows[r].cells[c].setAttribute("statistik", TOP_COLUMNS[Math.floor((c - 3) / 4) + 1]);
			}
		}
	}

	tableClone.rows[0].parentNode.removeChild(tableClone.rows[0]);
	tableClone.rows[tableClone.rows.length - 1].parentNode.removeChild(tableClone.rows[tableClone.rows.length - 1]);

	tableClone.id = "team";
	tableClone.style.marginTop = "25px";

	table.parentNode.replaceChild(tableClone, table);

	GM.addStyle('table[id^=team] td[art=LI] div div { margin-left:-8px !important; }');
	GM.addStyle('table[id^=team] td[art=LI] { padding-left:10px !important; }');

})();