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.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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;
}