NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ViciousCrow SGv2 Level Filter // @version 0.1 // @include http://www.steamgifts.com/ // @match http://www.steamgifts.com/ // @src // @grant unsafeWindow // @require http://code.jquery.com/jquery-latest.js // ==/UserScript== var l = 1 var max_page = $("[href^='/giveaways/search?page=']")[$("[href^='/giveaways/search?page=']").length-1].getAttribute("data-page-number"); function clearNotLevel() { var badGibs = document.getElementsByClassName('giveaway__row-inner-wrap'); var looping = badGibs.length; var gibsOk = 0; console.log('started clearing') for (var i = 0; i < looping; i++) { console.log([i]); if(typeof badGibs[gibsOk] == 'undefined') {break;} if (badGibs[gibsOk].getElementsByClassName('giveaway__column--contributor-level giveaway__column--contributor-level--positive').length > 0) { var level = badGibs[gibsOk].getElementsByClassName('giveaway__column--contributor-level giveaway__column--contributor-level--positive')[0].textContent; if (level.indexOf('0') == -1 && level.indexOf('1') == -1 && level.indexOf('2') == -1) { console.log('leaving'); gibsOk++; } else { console.log('removing'); badGibs[gibsOk].parentNode.removeChild(badGibs[gibsOk]); } } else { console.log('removing'); badGibs[gibsOk].parentNode.removeChild(badGibs[gibsOk]); } } //change padding for (var i = 0; i<document.styleSheets.length;i++) { console.log('changing padding'); try { document.styleSheets[i].insertRule('.giveaway__row-outer-wrap'+ '{padding:0}', document.styleSheets[i].cssRules.length); } catch(err) {try { document.styleSheets[i].addRule(selector, property+':'+value);} catch(err) {}} } var enteredGibs = document.getElementsByClassName('giveaway__row-inner-wrap is-faded'); //remove entered if(enteredGibs.length > 0) { console.log('removing entered'); for (var i = 0; i < enteredGibs.length; i++) { enteredGibs[i].parentNode.removeChild(enteredGibs[i]); i-- } } badGibs = document.getElementsByClassName('giveaway__row-outer-wrap'); var max = badGibs.length for (var i = 0; i < max; i++) { if(badGibs[i].getElementsByClassName('giveaway__row-inner-wrap').length == 0) { badGibs[i].parentNode.removeChild(badGibs[i]); i--; max--; } } }; function loadNextPages(){ if(l<max_page) { $("#p"+(l)).load("http://www.steamgifts.com/giveaways/search?page="+(l+1)+" .giveaway__row-outer-wrap", function() { l++; loadNextPages(); console.log('loaded page'+(l)) if(l==max_page) { clearNotLevel(); } }); } } function main(){ //logging vars console.log('max pages:'+max_page); //clearing main page var pinned = document.getElementsByClassName('pinned-giveaways'); if(pinned.length > 0) { pinned[0].parentNode.removeChild(pinned[0]); } var pinned2 = document.getElementsByClassName('featured__inner-wrap'); pinned2[0].parentNode.removeChild(pinned2[0]); var pinned3 = document.getElementsByClassName('featured__outer-wrap featured__outer-wrap--home'); pinned3[0].parentNode.removeChild(pinned3[0]); var pinned5 = document.getElementsByClassName('page__heading'); pinned5[0].parentNode.removeChild(pinned5[0]); //get giveaway container var newContent = document.getElementsByClassName('giveaway__row-outer-wrap'); var div = newContent[1].parentNode; var nowy = []; //create containers for loaded pages for(i=1; i<max_page; i++) { nowy[i] = newContent[0].cloneNode(false); nowy[i].id = 'p'+i; div.appendChild(nowy[i]); } //load pages loadNextPages(); } main();