NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name l2cBestMobsEver // @author Zeptor // @include http://l2central.info/classic/* var w; if (typeof unsafeWindow != undefined) { w = unsafeWindow } else { w = window; } if (w.self != w.top) { return; } if (/http:\/\/l2central.info\/classic/.test(w.location.href)) { if (getByText( "//td[text()='Земли\n']").snapshotLength === 1) { updateMobsTable(); } } function updateMobsTable() { var mobTable = document.querySelectorAll("div#mw-content-text>table.sortable")[0]; var headerCell = mobTable.querySelector("th"); ["Drop", "Spoil"].forEach(function(element) { var thNode = headerCell.cloneNode(true); thNode.setAttribute('width', '5%'); thNode.className = 'header'; thNode.innerHTML = element; headerCell.parentNode.appendChild(thNode); }); var mobRows = mobTable.querySelectorAll("tr"); for(var i = 1; i < mobRows.length; i++) { for (var j = 0; j < 2; j++) { var tdNode = document.createElement("td"); tdNode.setAttribute("align", "right"); tdNode.setAttribute("id", "td"+j); mobRows[i].appendChild(tdNode); } } for(var i = 1; i < mobRows.length; i++) { updateMobInfo(mobRows[i]); } } function updateMobInfo(mobRow) { var mobName = mobRow.querySelector("td>a").textContent; var query = "select A,R,S,T,U where A=\"" + mobName + "\""; function updateNodes(element, index) { mobRow.querySelector("td#td"+index).innerHTML = element; }; loadMobInfo("https://spreadsheets.google.com/tq?tq=" + encodeURIComponent(query) + "&key=1cTLdhZSqpiQxhfWo77YzD1KsT9zn8a-3_EQF-jk1rp4&gid=11655249", function(m) { if (m[1] == null) { ["?", "?"].forEach(updateNodes); } else { [(m[3].v + m[4].v) / 2, (m[1].v + m[2].v) / 2].forEach(updateNodes); } }); } function loadMobInfo(theUrl, callback) { GM_xmlhttpRequest({ method: "GET", url: theUrl, onload: function(response) { var jsonString = response.responseText; jsonString = jsonString.substring(jsonString.indexOf('(')+1, jsonString.lastIndexOf(')')); var resRow = JSON.parse(jsonString).table.rows[0]; if (resRow) { callback(resRow.c); } } }); } function getByText( xpath ){ return document.evaluate( xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); } // ==/UserScript==