Swagbucks App Completion

A script to print an alert to show how much you have progressed for each swagbucks app.

目前為 2014-09-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name       Swagbucks App Completion
// @namespace  https://github.com/Omegaice/SwagBucksAppMonitor
// @version    0.6
// @description A script to print an alert to show how much you have progressed for each swagbucks app.
// @match      http://www.swagbucks.com/account/summary
// @copyright  2014+, Omegaice
// ==/UserScript==

// App Maximums
var sbtv_max = 36;
var indymusic_max = 20;
var sportly_max = 52;
var entertainow_max = 90;
var movieclips_max = 80;

function CreateAppString(name, current, maximum, video_duration, videos_per_reward) {
    var result = name + ":\n";
    if( current == maximum ){
        result += "\tComplete [" + maximum + "/" + maximum + "]";
    }else{
        result += "\tIncomplete [" + current + "/" + maximum + "]";
    }
    result += "\n\tVideos Remaining: " + 5 * ((maximum-current)*0.5);
    return result + "\n\tEstimated Time Remaining: " + CalculateDuration(video_duration, current, maximum, videos_per_reward, 2);
}

// Time Variables
var advert_time = 30;
var nextup_time = 10;
var video_load_time = 5;

function CalculateDuration(minimum_time, current_points, maximum_points, videos_per_reward, reward_value){
    var remaining_points = maximum_points - current_points;
    var remaining_videos = remaining_points * (videos_per_reward / reward_value);
    var remaining_adverts = Math.floor(remaining_points / reward_value);

    var time = remaining_videos * (video_load_time + minimum_time + nextup_time) + remaining_adverts * advert_time;

    var hours = Math.floor(time / 3600) % 24;
    var minutes = Math.floor(time / 60) % 60;
    var seconds = time % 60;

    return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds  < 10 ? "0" + seconds : seconds);
}

$.get("http://www.swagbucks.com/?cmd=sb-acct-ledger&allTime=false",function(data,status){
    var values = data.split("|")[2].substr(1);
    values = values.substring(0, values.length - 1);

    var rewards = new Array();
    rewards[""] = 0;
    rewards["Sportly"] = 0;
    rewards["Indymusic"] = 0;
    rewards["EntertaiNow"] = 0;
    rewards["MovieCli.ps"] = 0;

    var lines = values.split("],");
    for( var i = 0; i < lines.length; i++ ){
        var lData = lines[i].replace("[", "").replace("]", "").split(",");

        var desc = lData[5].replace("'", "").replace("'", "").trim();
        if( rewards[desc] == null ){
            rewards[desc] = parseInt(lData[3]);
        }else{
        	rewards[desc] = rewards[desc] + parseInt(lData[3]);
        }
    }

    var result = "";

    result += CreateAppString("SBTV", rewards[""], sbtv_max, 9, 5) + "\n";
    result += CreateAppString("Indymusic.tv", rewards["Indymusic"], indymusic_max, 100, 10) + "\n";
    result += CreateAppString("Sportly.tv", rewards["Sportly"], sportly_max, 25, 10) + "\n";
    result += CreateAppString("EntertaiNow", rewards["EntertaiNow"], entertainow_max, 11, 10) + "\n";
    result += CreateAppString("MovieCli.ps", rewards["MovieCli.ps"], movieclips_max, 23, 10) + "\n";

    var combined_max = sbtv_max + indymusic_max + sportly_max + entertainow_max + movieclips_max;
    var combined = rewards[""] + rewards["Indymusic"] + rewards["Sportly"] + rewards["EntertaiNow"] + rewards["MovieCli.ps"];

    result += "\nTotal:\n"
    if(combined == combined_max){
        result += "\tComplete [" + combined_max + "/" + combined_max + "]";
    }else{
        result += "\tIncomplete [" + combined + "/" + combined_max + "]";
    }
    result += "\n\tVideos Remaining: " + (5 * ((50-rewards[""])*0.5) + 10 * ((20-rewards["Indymusic"])*0.5) + 10 * ((52-rewards["Sportly"])*0.5) + 10 * ((90-rewards["EntertaiNow"])*0.5) + 10 * ((80-rewards["MovieCli.ps"])*0.5));

    alert(result);
});