Greasy Fork

OP AutoJoin

OP Autojoin!

目前为 2016-04-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         OP AutoJoin
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  OP Autojoin!
// @author       You
// @match        http://www.opiumpulses.com/giveaways*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';


$( document ).ready(function() {
    
    var url = "http://www.opiumpulses.com/giveaways?Giveaway_page=[NUM_PAGE]&Giveaway_status=active&Giveaway_who_can_join=everyone";
    
    if (window.location.href.indexOf("http://www.opiumpulses.com/giveaways/") > -1) { //dentro de una aplicación
        
        setInterval(function(){ 
            window.close();
        }, 5000);
        
    } else {
    
        var giveaways = $('.btn-success');
    
        for (var x = 0 ; x < giveaways.length && x < 10; x ++ ){
            
            giveaways[x].setAttribute('target', '_blank');
            giveaways[x].click();   
        }
        
        if (giveaways.length == 0) { //no hay mas que aplicar a en esta página 
            
            var page = getParameterByName('Giveaway_page'); 
            
            if (page == null) {
                page=1;
            } else 
            {
                page++;
            }
            
            
            window.location="http://www.opiumpulses.com/giveaways?Giveaway_page=[NUM_PAGE]&Giveaway_status=active&Giveaway_who_can_join=everyone".replace("[NUM_PAGE]", page);
            
        } else 
        {
            setInterval(function(){ 
                window.location.reload();
            }, 6000);
        }
   
    }
    
    
  
});

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}



// Your code here...