Last active
August 30, 2023 15:40
-
-
Save NZDev0/fed2553343bc83716219bad8cd4aa9e5 to your computer and use it in GitHub Desktop.
GoG - Bookmarklets
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
//Bookmarklets for GoG, to install you have to create a bookmark and use the URLs as needed | |
//Removes tracker query params from embedded page urls | |
javascript:(function(){var links=document.querySelectorAll('a');links.forEach(link=>{if(link.href.includes("?source=news")){link.href=link.href.split('?')[0];}});})(); | |
//Clears the purple dot notification | |
javascript:(function(){angular.element(document.body).injector().get('menuNotificationsRepository').deleteAllNotifications();})(); | |
//Sorts wishlist by price, lowest to highest, highest to lowest etc | |
javascript:(function(){var%20elems=document.querySelectorAll('.list-inner');elems=elems[elems.length-1];var%20prices=Array.prototype.slice.call(document.querySelectorAll('.product-row-wrapper'),0);prices.sort(function(a,b){if(elems.classList.contains('sorted')){return%20parseFloat(b.querySelector('._price.product-state__price').textContent)-parseFloat(a.querySelector('._price.product-state__price').textContent);}return%20parseFloat(a.querySelector('._price.product-state__price').textContent)-parseFloat(b.querySelector('._price.product-state__price').textContent);});elems.innerHTML='';elems.classList.contains('sorted')?elems.classList.remove('sorted'):elems.classList.add('sorted');for(var%20i=0;i<prices.length;i++){elems.appendChild(prices[i]);}})(); | |
//restores profile data, games owned, achievements etc | |
javascript:(function(){fetch(`https://www.gog.com/userData.json`,{method:'GET',cache:'no-cache',headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(response=>{return%20response.json();}).then(json_data=>{let%20accountData=json_data;let%20shortfn=angular.element(document.body).injector().get("menuAccount");(shortfn.userGamesCount=accountData.purchasedItems.games||0,shortfn.userMoviesCount=accountData.purchasedItems.movies||0,shortfn.userWishlistedItemsCount=accountData.wishlistedItems||0,shortfn.userWalletBalance=accountData.walletBalance||0,shortfn.accountListenersManager.callListeners());}).catch((err)=>{console.log(`Error Occurred`);});})(); | |
//run this on your wishlist page (must be under 100 games) this removes games you added to your wishlist that GoG no longer offer | |
javascript:(function(){var%20a;fetch(`https://www.gog.com/user/wishlist.json`,{method:'GET',cache:'no-cache',headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(response=>{return%20response.json();}).then(jdata =>{a%20=%20jdata.wishlist;}).catch(()=>{}).finally(()=>{var%20x=document.querySelectorAll('.product-state-holder');var%20y=[];for(var%20i=0;i<x.length; i++){y.push(x[i].getAttribute('gog-product'));}a=Object.keys(a);var%20result=a.filter(item=>y.indexOf(item)==-1);if(result.length>0){for(var%20i=0;i<result.length;i++){fetch(`https://www.gog.com/user/wishlist/remove/${result[i]}`,{method:'GET',cache:'no-cache',headers:{"Content-Type": "application/x-www-form-urlencoded"}}).then(()=>{}).catch(()=>{}).finally(()=>{console.log(`Hidden item should now be removed`);})}}});})(); | |
//lists games that are delisted, however it also marks games sold/prime codes as sets as delisted | |
var totalPages; | |
fetch(`https://www.gog.com/en/account`, { | |
method:'GET', | |
cache:'no-cache' | |
}).then(response=>{ | |
return response.text(); | |
}).then($html =>{ | |
totalPages = /"totalPages":\s*(\d+),/.exec($html)[1]; | |
}).catch(()=>{}).finally(()=>{products_all();}) | |
function products_all(){ | |
for (let i = 0; i < totalPages; i++) { | |
fetch(`https://www.gog.com/account/getFilteredProducts?hiddenFlag=0&mediaType=1&page=${i+1}&sortBy=title&totalPages=${totalPages}`) | |
.then(response => response.json()) | |
.then(data => { | |
if (data.products && Array.isArray(data.products)) { | |
data.products.forEach(product => { | |
if (product.availability && product.availability.isAvailable !== undefined) { | |
const isAvailable = product.availability.isAvailable; | |
console.log('Product:', product.title, 'Availability:', isAvailable); | |
} | |
}); | |
} | |
}) | |
.catch(error => { | |
console.error('Fetch error:', error); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment