From 48a40b8058d6f5cf697ad114e2801a64cdd1f4d8 Mon Sep 17 00:00:00 2001 From: Abhorrent_Anger Date: Sun, 16 Aug 2026 20:29:25 +0300 Subject: [PATCH] Site update changes --- ManncoStoreGiveawayAutojoiner.user.js | 51 ++++++++++++++++++--------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/ManncoStoreGiveawayAutojoiner.user.js b/ManncoStoreGiveawayAutojoiner.user.js index 8395a77..ffa4fd5 100644 --- a/ManncoStoreGiveawayAutojoiner.user.js +++ b/ManncoStoreGiveawayAutojoiner.user.js @@ -1,12 +1,12 @@ // ==UserScript== // @name Mann Co. Store Giveaway Autojoiner -// @namespace https://pube.tk -// @version 2025-02-15 +// @namespace http://tampermonkey.net/ +// @version 2026-08-16 // @description Tries to join giveaways on page load // @author Abhorrent_Anger // @include /^https?:\/\/mannco\.store\/giveaways.?$/ // @icon https://www.google.com/s2/favicons?sz=64&domain=mannco.store -// @grant none +// @grant GM_xmlhttpRequest // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js // @require https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@v1.3/waitForKeyElements.js // @run-at document-end @@ -14,22 +14,39 @@ setTimeout(function () { location.reload(); }, 90 * 60 * 1000); -waitForKeyElements('a.raffle-list__item.list-group-item.list-group-item-action.raffleitem.isv.first', () => { +waitForKeyElements('.giveaways__content', () => { setTimeout(function () { - $('span[data-bs-title="Joined"][style*="display: none"]').each(function () { - let raffle = $(this).attr('url'); - let raffleJoinURL = 'https://mannco.store/requests/raffle.php?mode=join&url=' + raffle; - $.ajax({ - method: "GET", - xhrFields: { - withCredentials: true - }, - url: raffleJoinURL, - success: function (data) { - console.log('Tried to join ' + raffle + ' raffle, output: ' + data); + $('.giveaways-list-item:not(.giveaways-list-item--joined)').each(function () { + let giveawayURL = $(this).attr('href'); + let giveaway = /[^/]*$/.exec(giveawayURL)[0]; + let giveawayJoinURL = 'https://api.mannco.store/giveaways/join/' + giveaway; + + let bearerToken = getToken('auth'); + let csrfToken = getToken('csrf'); + + let xJoin = new GM_xmlhttpRequest({ + method: 'POST', + url: giveawayJoinURL, + headers: { 'Authorization': 'Bearer ' + bearerToken, 'X-Csrf-Token': csrfToken }, + onreadystatechange: function (response) { + if (response.readyState == 4 && response.status == 200) { + console.log('Successfully joined ' + giveaway, response.response); + } else { + console.log("Couldn't join " + giveaway, response); + } } }); }); - console.log('Done with raffle join attempts'); + console.log('Done with giveaway join attempts'); }, 2000); -}); \ No newline at end of file +}); + +const getCookieValue = (name) => ( + document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)')?.pop() || '' +) + +function getToken(tokenName) { + let authArray = getCookieValue(tokenName); + let decodedAuthArray = decodeURIComponent(authArray); + return JSON.parse(decodedAuthArray)['token']; +} \ No newline at end of file