Skip to content

Instantly share code, notes, and snippets.

@NikFlip
Created June 15, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikFlip/04e59d440b8218108f971b5754ff7a63 to your computer and use it in GitHub Desktop.
Save NikFlip/04e59d440b8218108f971b5754ff7a63 to your computer and use it in GitHub Desktop.
Endzeitspiel: Freie Händler Skript
(() => {
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