findClassNames() { let approvedRegex = /CardListItem__approved___[a-zA-Z0-9]{5}/; let rejectedRegex = /CardListItem__rejected___[a-zA-Z0-9]{5}/; let pendingRegex = /CardListItem__pending___[a-zA-Z0-9]{5}/;
for (let styleSheet of document.styleSheets) { try { for (let rule of styleSheet.cssRules) { if (!('selectorText' in rule)) { continue; } let selectorText = rule.selectorText; let match = null; if (approvedRegex !== null && (match = selectorText.match(approvedRegex)) !== null) { this.approvedClassName = match[0]; approvedRegex = null; } if (rejectedRegex !== null && (match = selectorText.match(rejectedRegex)) !== null) { this.rejectedClassName = match[0]; rejectedRegex = null; } if (pendingRegex !== null && (match = selectorText.match(pendingRegex)) !== null) { this.pendingClassName = match[0]; pendingRegex = null; } } } catch(e) { console.log(e); } } }
async load() { let page = 1; const token = JSON.parse(localStorage.user).authToken; let again = false; do { again = false; let response = await fetch('[https://apiportal.planetplus.com/api/Transaction/history?pageSize=100&pageNumber='](https://apiportal.planetplus.com/api/Transaction/history?pageSize=100&pageNumber=') + page.toString(), { headers: { "Authorization": "Bearer " + token } }); if (response.ok) { let payload = await response.json(); if (payload.numberOfAllItems > page * 100) { again = true; } for (let item of payload.items) { let entry = this.entryTemplate.cloneNode(true); entry.querySelector('div[class^="CardListItem__network"]').textContent = item.shopName; const d = new Date(item.creationDate); entry.querySelector('div[class^="CardListItem__date"]').textContent = d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2) + ' ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2) + ':' + ('0' + d.getSeconds()).slice(-2); entry.querySelector('div[class^="CardListItem__spent"]').textContent = item.spent.toFixed(2) + ' ' + item.currencyCode; entry.querySelector('div[class^="CardListItem__value"]').textContent = item.cashback.toFixed(2); let status; switch(item.cashbackStatus) { case 0: status = 'Oczekiwany'; entry.classList.add(this.pendingClassName); break; case 1: status = 'Uznany'; entry.classList.add(this.approvedClassName); break; case 2: status = 'Odrzucony'; entry.classList.add(this.rejectedClassName); break; } entry.querySelector('div[class^="CardListItem__status"]').textContent = status;
@widmo82: 1. wywala paginację po 10 wpisów i ładuje wszystkie transakcje 2. dodaje zielone/czerwone tło, żeby od razu było widać status transakcji 3. usuwa marginesy pomiędzy wpisami
@kelaib: dzięki, świetna robota. Nie zmienia to faktu że jak będę miał wszystko zaliczone to wypłacam i się zwijam na inną platformę... Tyle lat ich broniłem ale ten hucznie zapowiadany nowy system to jakiś żart :/
// ==UserScript==
// @name PP - naprawa po debilach
// @version 0.1
// @match [https://planetplus.com/uzytkownik/cashback](https://planetplus.com/uzytkownik/cashback)
// @grant none
// ==/UserScript==
(function() {
'use strict';
class PPdebile
{
constructor()
{
this.interval = setInterval(() => {this.start()}, 100);
}
start()
{
document.querySelector('div[class^="Pagination__indicatorsContainer"]').innerHTML = '';
this.container = document.querySelector('div[class^="LastTransactions__cardBackground"]');
if (this.container === null) {
return;
}
clearInterval(this.interval);
this.findClassNames();
let style = document.createElement('style');
style.appendChild(document.createTextNode(''));
document.head.appendChild(style);
style.sheet.insertRule('.' + this.container.className.split(' ')[0] + ' > div {padding-top: 0 !important; padding-bottom: 0 !important;}');
style.sheet.insertRule('.' + this.approvedClassName + ' {background: green; }');
style.sheet.insertRule('.' + this.rejectedClassName + ' {background: red; }');
this.entryTemplate = this.container.firstChild.cloneNode(true);
this.entryTemplate.classList.remove(this.approvedClassName);
this.entryTemplate.classList.remove(this.rejectedClassName);
this.entryTemplate.classList.remove(this.pendingClassName);
this.container.innerHTML = '';
this.load();
}
findClassNames()
{
let approvedRegex = /CardListItem__approved___[a-zA-Z0-9]{5}/;
let rejectedRegex = /CardListItem__rejected___[a-zA-Z0-9]{5}/;
let pendingRegex = /CardListItem__pending___[a-zA-Z0-9]{5}/;
for (let styleSheet of document.styleSheets) {
try {
for (let rule of styleSheet.cssRules) {
if (!('selectorText' in rule)) {
continue;
}
let selectorText = rule.selectorText;
let match = null;
if (approvedRegex !== null && (match = selectorText.match(approvedRegex)) !== null) {
this.approvedClassName = match[0];
approvedRegex = null;
}
if (rejectedRegex !== null && (match = selectorText.match(rejectedRegex)) !== null) {
this.rejectedClassName = match[0];
rejectedRegex = null;
}
if (pendingRegex !== null && (match = selectorText.match(pendingRegex)) !== null) {
this.pendingClassName = match[0];
pendingRegex = null;
}
}
} catch(e) {
console.log(e);
}
}
}
async load()
{
let page = 1;
const token = JSON.parse(localStorage.user).authToken;
let again = false;
do {
again = false;
let response = await fetch('[https://apiportal.planetplus.com/api/Transaction/history?pageSize=100&pageNumber='](https://apiportal.planetplus.com/api/Transaction/history?pageSize=100&pageNumber=') + page.toString(), {
headers: {
"Authorization": "Bearer " + token
}
});
if (response.ok) {
let payload = await response.json();
if (payload.numberOfAllItems > page * 100) {
again = true;
}
for (let item of payload.items) {
let entry = this.entryTemplate.cloneNode(true);
entry.querySelector('div[class^="CardListItem__network"]').textContent = item.shopName;
const d = new Date(item.creationDate);
entry.querySelector('div[class^="CardListItem__date"]').textContent = d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2) + ' ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2) + ':' + ('0' + d.getSeconds()).slice(-2);
entry.querySelector('div[class^="CardListItem__spent"]').textContent = item.spent.toFixed(2) + ' ' + item.currencyCode;
entry.querySelector('div[class^="CardListItem__value"]').textContent = item.cashback.toFixed(2);
let status;
switch(item.cashbackStatus) {
case 0:
status = 'Oczekiwany';
entry.classList.add(this.pendingClassName);
break;
case 1:
status = 'Uznany';
entry.classList.add(this.approvedClassName);
break;
case 2:
status = 'Odrzucony';
entry.classList.add(this.rejectedClassName);
break;
}
entry.querySelector('div[class^="CardListItem__status"]').textContent = status;
this.container.appendChild(entry);
}
}
page++;
} while(again);
}
}
new PPdebile();
})();
#planetplus
1. wywala paginację po 10 wpisów i ładuje wszystkie transakcje
2. dodaje zielone/czerwone tło, żeby od razu było widać status transakcji
3. usuwa marginesy pomiędzy wpisami