ge-ku / AutoJoin-for-SteamGifts

Automatically enters giveaways from Steamgifts.com
https://chrome.google.com/webstore/detail/autojoin-for-steamgifts/bchhlccjhoedhhegglilngpbnldfcidc
GNU General Public License v2.0
105 stars 22 forks source link

[Feature Request] Hide Giveaways below a given level #29

Closed BlaM closed 6 years ago

BlaM commented 6 years ago

... for example I would like to hide all "Level 0" giveaways and not spend my points to battle with all the freeloaders on the site.

PredatorIWD commented 6 years ago

I guess this hasn't been added yet since this doesn't seem to be a popular request, but anyway, I have created a simple userscript for you that you can use with Tampermonkey to hide all Level 0 giveaways.

// ==UserScript==
// @name         Remove Level 0 SteamGifts Giveaways
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description
// @author       PredatorIWD
// @match        https://www.steamgifts.com/*
// @grant        none
// ==/UserScript==

setInterval(function() {
    $("div[data-game-id]").each(function() {
        if (this.getElementsByClassName("giveaway__column--contributor-level giveaway__column--contributor-level--positive").length != 1) {
            this.remove();
        }
    });
}, 200);
BlaM commented 6 years ago

Thank you, looks good. Haven't used Tampermonkey for years though (UserScripts.com has become too overwhelming and full of old scripts back then - and doesn't seem to exist anymore today?).

Time to try again... I think...

sy0ux commented 6 years ago

@PredatorIWD I support the request of BlaM. Anyway, your userscript removes those giveaways that dont specify the level, right? How would it be, for example, to hide those giveaways below level 4 or 5...? I have limited programming knowledge.

Thanks for your attention.

PredatorIWD commented 6 years ago

@sy0ux I have modified the userscript so that you can hide all giveaways below a desired level. You can now simply change the removeAllBelowLevel variable below and the script should do its job.

I guess this could be integrated into the AutoJoin extension, but there are probably other priorities that need addressing and I myself don't use this extension anymore and hardly the site itself, but if there are some minor tweaks or useful features that are required I don't mind helping.

Cheers

// ==UserScript==
// @name         SteamGifts Giveaways Level Filter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Removes all giveaways below a specified level on SteamGifts.com
// @author       PredatorIWD
// @match        https://www.steamgifts.com/*
// @grant        none
// ==/UserScript==

var removeAllBelowLevel = 4;

setInterval(function() {
    $("div[data-game-id]").each(function() {
        if ($(this).find(".giveaway__column--contributor-level").length > 0) {
            if ($(this).find("div[title='Contributor Level']")[0].textContent.substr(5, 2) < removeAllBelowLevel) {
                this.remove();
            }
        } else if (removeAllBelowLevel > 0) {
            this.remove();
        }
    });
}, 200);
ge-ku commented 6 years ago

I'll try to add it in a moment. Sorry for not updating the extension frequently. Motivation is low since I rarely visit Steamgifts nowadays. I also wanted to do a rewrite, started doing it and never finished, so currently code is kinda messy. There also were great commits by @Zakanator which added neat filtering but in my testing slowed down initial loading of extension (not his fault, currently logic is tied to UI) and I was not sure if I should publish it.

ge-ku commented 6 years ago

Here it is. I'll now upload it to Chrome store and later to Firefox. Tell me if it works or not (version is 1.6.4). You can also tell me if you notice any slowdowns, since this update also includes commits mentioned above.

souf-c commented 6 years ago

last update broke the app (using chrome)

ge-ku commented 6 years ago

@souf-c can you please check if there are any errors in your console? It works for me so I'm not sure what could be the problem.

sy0ux commented 6 years ago

@PredatorIWD Thank you for your quick answer. Your userscript works perfectly, thanks again for that. @ge-ku Yes, the extension, at least in chrome, seems broken for me too.

souf-c commented 6 years ago

Failed to load https://steamcommunity.com/profiles/76561197988617764/games/?tab=all: Redirect from 'https://steamcommunity.com/profiles/76561197988617764/games/?tab=all' to 'https://steamcommunity.com/id/xxx/games?tab=all' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://bchhlccjhoedhhegglilngpbnldfcidc' is therefore not allowed access. (index):1 Failed to load https://steamcommunity.com/profiles/76561197988617764/wishlist: Redirect from 'https://steamcommunity.com/profiles/76561197988617764/wishlist' to 'https://steamcommunity.com/id/xxx/wishlist' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://bchhlccjhoedhhegglilngpbnldfcidc' is therefore not allowed access. autoentry.js:197 Uncaught TypeError: Cannot read property 'children' of null at pageDOM.querySelectorAll.forEach (autoentry.js:197) at NodeList.forEach (<anonymous>) at modifyPageDOM (autoentry.js:127) at onPageLoad (autoentry.js:609) at XMLHttpRequest.wishxhr.onreadystatechange (autoentry.js:332)

sy0ux commented 6 years ago

same errors in my console

ge-ku commented 6 years ago

Thanks, seems like this issue appears when there are no pinned giveaways left, I uploaded new version (1.6.4.1), should be updated soon. Please let me know if it works.

sy0ux commented 6 years ago

@ge-ku Now it seems to work correctly, good job!

ge-ku commented 6 years ago

Great, feel free to open new issue if something else breaks :)