Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @id steamlove
- // @name steamlove
- // @version 2.0.2
- // @namespace
- // @author http://www.steamgifts.com/user/EyEBURNeR
- // @description giveaway management helper. working with steamgifts v2
- // @include http://www.steamgifts.com/*
- // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
- // @run-at document-end
- // ==/UserScript==
- //prepare globals
- var bundle_list = [];
- var ga_list = [];
- var ga = [];
- var ga_count = 0;
- var ga_progress = 0;
- eleg_menu();
- function eleg_menu() {
- //add eleg menu
- var btn_tpl = $('nav:first .nav__button[href*="support"]').parent();
- $('.fa', btn_tpl).removeClass('.fa-plus-circle icon-green');
- var nav = $(btn_tpl).clone();
- $('.nav__button:first', nav).text('ELEG').attr('href', '#');
- var navrow_tpl = $('.nav__row:first', nav).clone();
- $('.nav__row', nav).remove();
- var row = [{name: 'Current ELEG giveaways', description: 'FTW', href: '#', icon: 'fa-trophy icon-green', id: 'eleg_ftw'}];
- for (i in row) {
- var navrow = $(navrow_tpl).clone();
- $(navrow).attr('href', row[i].href).attr('id', row[i].id);
- $('.nav__row__summary__name', navrow).text(row[i].name);
- $('.nav__row__summary__description', navrow).text(row[i].description);
- $('.fa', navrow).addClass(row[i].icon);
- $('.nav__absolute-dropdown', nav).append(navrow);
- }
- $(btn_tpl).parent().append(nav);
- }
- $('nav:first').on('click', '#eleg_ftw', function () {
- $('.featured__container').remove();
- var box = $('.page__inner-wrap:first');
- $(box).html('test').attr('id', 'eleg');
- $('.notification', '#eleg').remove();
- document.title = 'Steam Gifts Eleg Management';
- $('#eleg').html('<div>Paste source code of <a target="_blank" style="font-weight:bold;color:green;" href="http://steamcommunity.com/groups/EverybodyLEG/discussions/0/864972399765669380/"> <li class="fa fa-external-link"></li> eleg open ga list</a> then click the button:</div>');
- $('#eleg')
- .append($('<div style="height:100px !important;overflow:hidden"></div>')
- .append($('<textarea/>').attr('id', 'source').attr('style', 'width:100%')))
- .append($('<a class="featured__action-button" href="#"><i class="fa fa-arrow-circle-right"></i> Check</a>').click(elegCheckGaList))
- ;
- });
- function parseGaDone() {
- ga_progress++;
- $('#progress').val(ga_progress);
- if (ga_progress == ga_count) {
- $('#progress').remove();
- elegCheckDone();
- }
- }
- function elegCheckGaList() {
- $(this).after('<progress id="progress"></progress>');
- $(this).remove();
- var list = $('.forum_op .content', $('#source').val());
- $('a[href*="/giveaway/"]', list).each(function(){
- ga_list.push($(this).attr('href'));
- });
- for(i in ga_list)
- ga[i]={'href':ga_list[i]}
- ga_count=ga.length;
- $('#progress').attr('max',ga_count);
- //getBundleList();
- for(i=0;i<ga_count;i++){
- populateGa(i);
- }
- }
- function elegCheckDone() {
- $('#eleg').append('<h4>Result : </h4>');
- var obj = $('<table/>');
- var tr = $('<tr/>');
- $(tr)
- .append($('<th/>').text('link'))
- .append($('<th/>').text('title'))
- .append($('<th/>').text('giver'))
- .append($('<th/>').text('cv'))
- .append($('<th/>').text('status/winner'))
- .append($('<th/>').text('B'))
- .append($('<th/>').text('NB'))
- .append($('<th/>').text('entries'))
- .append($('<th/>').text('date'))
- ;
- $(obj).append(tr);
- for (i in ga) {
- var g = ga[i];
- var tr = $('<tr/>');
- var ga_url='http://www.steamgifts.com/giveaway/' + g.id +'/';
- $(tr)
- .append($('<td/>').html('<a href="'+ga_url+'">'+ga_url+'</a>'))
- .append($('<td/>').text(g.title + ','))
- .append($('<td/>').text(g.giver))
- .append($('<td/>').text(g.is_bundle ? 0 : g.cv))
- .append($('<td/>').text(g.status == 'CLOSED' ? g.winner : g.status))
- //.append($('<td/>').text(g.is_bundle ? 1 : 0))
- //.append($('<td/>').text(g.is_bundle ? 0 : 1))
- .append($('<td/>').text('?'))
- .append($('<td/>').text('?'))
- .append($('<td/>').text(g.entries))
- .append($('<td/>').text(g.date))
- ;
- $(obj).append(tr);
- }
- GM_addStyle("#eleg table td{border:1px solid #333}");
- $('#eleg').append(obj);
- }
- function populateGa(gaIdx) {
- var url = ga[gaIdx].href;
- url = url.substring(url.indexOf('url=') + 4);
- $.ajax({
- url: url,
- success: function (page) {
- ga[gaIdx] = $.extend(ga[gaIdx], parseGa(page, url));
- parseGaDone();
- },
- dataType: 'html'
- });
- }
- function parseGa(page, url) {
- var g = {};
- try {
- var winners = [];
- g.title = $.trim($('.featured__heading__medium:first', page).text());
- g.giver = $('.featured__column a[href*="/user/"]:first', page).text();
- g.winner = '';
- g.winners = [];
- g.status = '';
- g.is_failed = false;
- g.is_open = false;
- g.is_closed = false;
- g.is_pending = false;
- g.date = $('.featured__column .fa-clock-o', page).parent().find('span:last').text();
- g.entries = parseInt($('.live__entry-count', page).text());
- g.id = url.split('/giveaway/')[1].split('/')[0];
- g.cv = $('.featured__heading>div.featured__heading__small:last', page).text().split('(')[1].split('P')[0];
- if (g.date.indexOf('Ended ') > -1) {
- urlwinners = $('.sidebar__navigation__item__link[href*="/winners"]', page).attr('href');
- var wdiv;
- $.ajax({
- url: urlwinners,
- async: false,
- success: function (wpage) {
- wdiv = $('.page__inner-wrap', wpage);
- },
- dataType: 'html'
- });
- g.is_closed = true;
- g.status = 'CLOSED';
- var received = $('.table__row-inner-wrap', wdiv);
- if (received.length) {
- $(received).each(function () {
- if ($(this).closest('.table__row-outer-wrap').find('.fa-check-circle').length) {
- winners.push($('a[href*="/user/"]',this).text());
- } else if($(this).closest('.table__row-outer-wrap').find('.fa-question-circle').length) {
- winners.push('PENDING');
- g.is_pending = true;
- g.status = 'PENDING';
- }else {
- winners.push('NOT RECEIVED');
- }
- });
- } else {
- winners.push('FAILED');
- g.is_failed = true;
- g.status = 'FAILED';
- }
- g.winners = winners;
- g.winner = winners.join(',');
- } else {
- g.is_open = true;
- g.status = 'OPEN';
- }
- /*
- g.is_bundle=($.inArray(g.title, bundle_list)>-1);
- */
- } catch (e) {
- }
- return g;
- }
- /*
- function getBundleList(){
- $.ajax({
- url: 'http://www.steamgifts.com/create',
- async:false,
- success: function (page) {
- $('#create_form', page).find('option','select:first').each(function(){
- if($(this).text().replace(/[^*]/g, "").length)
- bundle_list.push($(this).text().replace(' *',''));
- });
- },
- dataType: 'html'
- });
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment