// ==UserScript== // @name GOG Orders history prices summary // @version 1.52 // @namespace XcomeX // @author XcomeX // @license Copyleft (Ɔ) GPLv3 // @description Sum paid and original prices on orders history pages and get your total saved money on sales. Add new button (SUM ORDERS on this page) on Orders history page in settings. // @include https://www.gog.com/account/settings/orders // @grant GM_addStyle // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js // @downloadURL https://update.greasyfork.org/scripts/14022/GOG%20Orders%20history%20prices%20summary.user.js // @updateURL https://update.greasyfork.org/scripts/14022/GOG%20Orders%20history%20prices%20summary.meta.js // ==/UserScript== var targBtnLocation = document.getElementsByClassName("_search orders-header__search")[0].parentNode; var zNode = document.createElement ('div'); zNode.innerHTML = ' '; zNode.setAttribute ('id', 'sumContainer'); targBtnLocation.appendChild (zNode); var xNode = document.createElement ('div'); xNode.setAttribute ('id', 'sumResultsContainer'); targBtnLocation.appendChild (xNode); var yNode = document.createElement ('div'); yNode.setAttribute ('id', 'totalSumContainer'); targBtnLocation.appendChild (yNode); document.getElementById ("sumPageButton").addEventListener ( "click", SumPageButtonClickAction, false ); document.getElementById ("sumAllButton").addEventListener ( "click", SumAllPagesButtonClickAction, false ); $( ".pagin" ).click(function() { window.scrollTo(0, 0); }); GM_addStyle ( " \ #sumContainer { \ float: right; \ } \ .sumRow { \ font-weight: 100; \ } \ .priceSum { \ width: 51px; \ display: inline-block; \ } \ #sumAllButton, #sumPageButton { \ color: #262626; \ font-weight: 600; \ font-size: 14px \ line-height: 1.5; \ position: relative; \ top: 10px; \ background: #E0E0E0; \ border: none; \ padding-top: 3px; \ } \ #sumAllButton { \ color: #ffffff; \ background: #337ab7; \ } \ .deleteSumRowButton { \ color: gray; \ font-size: 11px; \ line-height: 1.5; \ background: none; \ border: none; \ bottom: 2px; \ position: relative; \ } \ #sumAllButton:hover { \ background: #286090; \ } \ #sumPageButton:hover { \ background: #EBEBEB; \ } \ .deleteSumRowButton:hover { \ text-decoration: underline; \ } \ #sumResultsContainer, #totalSumContainer { \ text-align: right; \ } \ " ); async function SumNextPageAction() { var page = getCurrentPage(); var totalPages = getTotalPages(); if (page == totalPages) { return; } else { $(".pagin__next").click(); sleep(800).then(() => { SumPageAction(); SumNextPageAction(); }) } } function SumAllFromFirstPageAction() { $(".pagin__prev").click(); sleep(500).then(() => { var page = getCurrentPage(); if (page == "1") { SumPageAction(); SumNextPageAction(); return; } SumAllFromFirstPageAction(); }) } function SumPageButtonClickAction (zEvent) { SumPageAction(); } function SumAllPagesButtonClickAction (zEvent) { SumAllFromFirstPageAction(); } // --------------------------------------------------------------------------------- function SumPageAction () { $("#sumResultsContainer").append(SumRow()); $(".deleteSumRowButton").each(function( index ) { $(this).click(function() { $(this).closest('div').remove(); $("#totalSumContainer").html(TotalSumRow()); }); }); $("#totalSumContainer").html(TotalSumRow()); } function SumRow() { purchasePrice = SumPurchasePrices().toFixed(2); originalPrice = SumOriginalPrices().toFixed(2); saved = (originalPrice - purchasePrice).toFixed(2); currency = ""; page = pad(getCurrentPage()); totalPages = getTotalPages(); sumRow = "