Last active
July 28, 2023 13:59
-
-
Save ImMALWARE/d88acea255d6d38d7e9893c80d65fad0 to your computer and use it in GitHub Desktop.
Сумма платежей в профиле Lolzteam
This file contains hidden or 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
// ==UserScript== | |
// @name Сумма платежей в профиле Lolzteam | |
// @description Расширение, которое возвращает сумму платежей в Lolzteam | |
// @author MALWARE | |
// @homepage https://t.me/immalware/ | |
// @include https://lolz.guru/market/user/*/payments* | |
// @namespace lolzteam_payment_history | |
// @run-at document-end | |
// @version 2.1 | |
// @license MIT | |
// @icon https://lolz.guru/favicon.ico | |
// ==/UserScript== | |
/* globals jQuery, $, waitForKeyElements */ | |
/* jshint esversion:6 */ | |
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms));} | |
if(document.getElementsByClassName('marketIndex--titleContainer') != null && document.getElementsByClassName('marketIndex--titleContainer')[0].getAttribute('style').includes('display')) { | |
let currentScrollHeight = 0; | |
let scrollAttempts = 0; | |
while (scrollAttempts < 5) { | |
currentScrollHeight = document.body.scrollHeight; | |
window.scrollTo(0, currentScrollHeight); | |
await(sleep(1000)); | |
if (currentScrollHeight === document.body.scrollHeight) { | |
scrollAttempts++; | |
} | |
else { | |
scrollAttempts = 0; | |
} | |
} | |
window.scrollTo(0, 0); | |
var div = document.createElement('div'); | |
var incomes = eval($(".in").text().replace(/\s/g, '')); if(incomes == null) {incomes = 0}; | |
var outcomes = eval($('[class="out"]').text().replace(/\/ [\d.]+/g, '').replace(/[\n\t]/g, '-').replace(/\-+/g, '-').replace(/\s/g, '').replace(/\-$/, '')); if(outcomes == null) {outcomes = 0} else {outcomes = outcomes.toString().replace('-', ' ')}; | |
var sender; | |
if(window.location.search.includes('?sender=')) {sender = 'от '+new URLSearchParams(window.location.search).get('sender')} else if(window.location.search.includes('?receiver=')) {sender = 'для '+new URLSearchParams(window.location.search).get('receiver')} else {sender = 'за <span class="Label">всё время</span>'} | |
div.innerHTML = '<div class="marketIndex--titleContainer" style="padding: 0px 0px 20px; display: "><div class="bottom"><div class="paymentStats"><div class="fl_l title">Сумма платежей '+sender+'</div><div class="fl_r stats"><span class="stat bold mainc">+ <span class="Incomes">'+incomes+'</span> <span class="svgIcon--rub green fs-17px bold"></span></span><span class="stat bold">- <span class="Outgoings">'+outcomes+'</span> <span class="svgIcon--rub fs-17px bold"></span></span></div></div></div></div>'; | |
var container = document.getElementsByClassName('market--userPaymentsFilter')[0]; | |
container.insertBefore(div, container.firstChild); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment