Swagbucks.com Swag Code Checker

Will check sc-s.com for new swagbucks.com swag codes, paste them into the form for you, then alert you. It checks on page load and every 30 minutes while http://www.swagbucks.com/account/summary is open.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Advertisement:

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

Advertisement:

// ==UserScript==
// @name        Swagbucks.com Swag Code Checker
// @description	Will check sc-s.com for new swagbucks.com swag codes, paste them into the form for you, then alert you.  It checks on page load and every 30 minutes while http://www.swagbucks.com/account/summary is open.
// @namespace   https://greasyfork.org/en/users/710-tjololo
// @version     0.1
// @include     http://www.swagbucks.com/account/summary*
// @require     http://code.jquery.com/jquery-latest.min.js
// @grant		GM_xmlhttpRequest
// ==/UserScript==


//  Shameless self promotion: Use my referal link if you're signing up! 
// http://www.swagbucks.com/refer/johngoner778 or http://www.irazoo.com/ReferedNewUser.aspx?RefBy=johngoner778

window.addEventListener ("load", localMain(), false);

function localMain(){
    if (document.location.href.search("swagbucks.com")  != -1){
        checkCode();
        window.setInterval(checkCode,10*60*1000);
    }  else {
    }
}

function simulateClick(obj) {
    var evt = document.createEvent("MouseEvents");
    evt.initMouseEvent("click", true, true, window,
                       0, 0, 0, 0, 0, false, false, false, false, 0, null);
    var canceled = !obj.dispatchEvent(evt);      
}

function checkCode(){
    GM_xmlhttpRequest({
        method: "GET",
        url: "http://sc-s.com",
        headers: {
            "User-Agent": "Mozilla/5.0",    // If not specified, navigator.userAgent will be used.
            //   "Accept": "text/xml"            // If not specified, browser defaults will be used.
        },
        onload: function(response) {

            process(response);

        }
    });
}

function process(response){

    var resp = $.parseHTML(response.responseText);
    var el = $( '<div></div>' );
    el.html(resp);
    var code2 = $('div[data-code-type="swagbucks"][data-countries*=us]',el).attr("data-code");
    /*alert(code);

    var patt=new RegExp('<td class="value p_code">.+</td>');
    var code = patt.exec(response.responseText);

    var code2 = new String(code);
    code2 = code2.replace('<td class="value p_code">','');
    code2 = code2.replace('</td>','');*/

    if(code2 == null){
        alert('error no code');
    }

    if(getCookie("code") !=code2){
        setCookie("code",code2,365);
        alert("new swag promo code: " + code2);
        document.querySelector('*[id="pcode"]').value = code2;
    }else{
        document.querySelector('*[id="pcode"]').value = code2;
    }

}

function getCookie(c_name)
{
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");
        if (x==c_name)
        {
            return unescape(y);
        }
    }
}

function setCookie(c_name,value,exdays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
}