script auto promo tokopedia

tokopedia

tokopedia

Bagi yang buka lapak di tokopedia pasti tau kan ding/promo, itu konsepnya mirip kayak ‘sundul gan’ di kaskus, bedanya klo di kaskus masih serba manual klo di tokopedia dah otomatis, tinggal klik nnti muncul di page one,  dan ‘jatah’nya masing2 toko itu 1 jam, jadi klo dah lewat 1 jam baru boleh ding lagi.. Nah bagaimana caranya klo kliknya otomatis? setelah dipasang nilai counter tertentu lalu klik otomatis? bisa aja, caranya pake greasemonkey di firefox, lalu dengan sdikit script 😀 

// ==UserScript==
// @name        auto-ding
// @namespace   test
// @description auto ding tokopedia
// @include     http://www.tokopedia.com/<nama toko kamu>/*
// @version     1
// @author       panji https://ruangpanji.wordpress.com
// ==/UserScript==
$( document ).ready(function() {
    //check initialisation session storage
    if(typeof sessionStorage.cding=='undefined' || typeof sessionStorage.cding_save=='undefined'){
        sessionStorage.cding='0';
        sessionStorage.cding_save='0';
    }
    if(typeof sessionStorage.crefresh=='undefined')
        sessionStorage.crefresh='0';

    //interface
    $html ='<table id="s-show"><tr><td>countdown ding</td><td id="s-minute"></td</tr><tr><td>countdown refresh</td><td id="s-refresh"></td</tr></table>';
    $html =$html+'counter auto ding: <input id="c-ding" type="text" style="width:30px" value="'+sessionStorage.cding_save+'"></input> minute<br>';
    $html =$html+'counter auto refresh: <input id="c-refresh" type="text" style="width:30px" value="'+sessionStorage.crefresh+'"></input> minute<br>';
    $html =$html+'<input id="s-submit" type="button" value="submit"><input id="s-cancel" type="button" value="cancel">';
    $('.span5.product-image-holder').prepend($html);

    //check countdown running
    if(sessionStorage.start=='true' && typeof sessionStorage.start !=='undefined'){
        $('#c-refresh').attr('disabled','disabled');
        $('#c-ding').attr('disabled','disabled');
        $('#s-minute').html(sessionStorage.cding);
        $('#s-refresh').html($('#c-refresh').val());
        $('#s-show').show();
        start_ding();

    }else{
        $('#c-ding').removeAttr('disabled');
        $('#c-refresh').removeAttr('disabled');
        $('#s-show').hide();
    }

    //even if click submit
    $('#s-submit').click(function(){
        $('#c-ding').attr('disabled','disabled');
        $('#c-refresh').attr('disabled','disabled');
        sessionStorage.cding=$('#c-ding').val();
        sessionStorage.cding_save=sessionStorage.cding;
        sessionStorage.crefresh=$('#c-refresh').val();
        sessionStorage.start='true';
        $('#s-minute').html($('#c-ding').val());
        $('#s-refresh').html($('#c-refresh').val());
        $('#s-show').show();

        start_ding();
    });

    //even if click cancel
    $('#s-cancel').click(function(){
        $('#c-ding').removeAttr('disabled');
        $('#c-refresh').removeAttr('disabled');
        $('#s-show').hide();
        sessionStorage.start='false';
    });

    function start_ding(){
        var refresh = sessionStorage.crefresh;
        if(sessionStorage.cding != 0 && sessionStorage.crefresh != 0)
            var counter=setInterval(timer, 60*1000); //1000 will  run it every 1 minute

        function timer(){
            if(sessionStorage.start=='true'){
                sessionStorage.cding=sessionStorage.cding-1;
                refresh=refresh-1;

                $('#s-minute').html(sessionStorage.cding);
                $('#s-refresh').html(refresh);
                if (sessionStorage.cding <= 0){
                    clearInterval(counter);
                    //counter ended, do something here
                    $("#dink-it").click();
                    //location.reload();
                    return;
                }else if (refresh <=0)
                    location.reload();
                //Do code for showing the number of seconds here
                console.log(sessionStorage.cding+" minute");
            }else{
                clearInterval(counter);
            }

        }
    }

});

copy kode di atas, lalu ganti <nama toko kamu>, lalu save dengan nama auto-ding.user.js lalu drag file js ke firefox, install finish!

and well, let’s play how it’s works,

screenshot sebelum menggunakan script

sebelum menggunakan script

setelah menggunakan script

dengan script

dengan script

isi counter auto ding untuk hitung mundur berapa menit lagi untuk klik ‘promo’ lalu isi counter auto refresh untuk isi berapa menit si browser bakal merefresh, ini gunanya agar session login tetap ada lalu klik submit.

sekian, smoga berguna 🙂

salam

panji.

Iklan