Created
June 15, 2020 14:32
-
-
Save NikFlip/04e59d440b8218108f971b5754ff7a63 to your computer and use it in GitHub Desktop.
Endzeitspiel: Freie Händler Skript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
if (window.location.search.indexOf('cms=haendler') === -1) { | |
return; | |
} | |
const $buy = $('[name="kaufen"]'); | |
const $buyMainTable = $buy.next('table'); | |
const $buyTables = $buyMainTable.find('table'); | |
const $sell = $('[name="verkaufen"]'); | |
const $sellMainTable = $sell.next('table'); | |
const $sellTables = $sellMainTable.find('table'); | |
function extractSellInformation($table) { | |
const resType = $table.find('tbody tr:first-child td:last-child b').text().trim(); | |
const singleCost = $table.find('tbody tr:nth-child(2) td:last-child').text().trim(); | |
const maxAmount = $table.find('tbody tr:nth-child(3) td:last-child').text().trim(); | |
return `<p><strong>${resType}</strong><br />Kaufpreis: ${singleCost}<br />Maximum: ${maxAmount}</p>`; | |
} | |
function extractBuyInformation($table) { | |
const resType = $table.find('tbody tr:first-child td:last-child b').text().trim(); | |
const singleCost = $table.find('tbody tr:nth-child(2) td:last-child').text().trim(); | |
return `<p><strong>${resType}</strong><br />Verksaufpreis: ${singleCost}</p>`; | |
} | |
const text = ['<div style="display: flex;"><div style="flex: 1;"><strong>Kaufen</strong><br /><br />']; | |
$buyTables.each((index, table) => text.push(extractSellInformation($(table)))); | |
text.push('</div><div style="flex: 1;"><strong>Verkaufen</strong><br/><br />'); | |
$sellTables.each((index, table) => text.push(extractBuyInformation($(table)))); | |
text.push('</div></div>'); | |
const ressWindow = window.open('', 'Endzeitspiel Handelsseite', 'width=400,height=500'); | |
ressWindow.document.body.innerHTML = text.join(''); | |
ressWindow.document.body.style.padding = '1rem' | |
const style = document.createElement('link'); | |
style.href = 'https://endzeitspiel.de/assets/css/endzeitspiel.css'; | |
style.rel = 'stylesheet'; | |
ressWindow.document.head.appendChild(style); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment