CrowdSurfWork productivity extension

Hide the copyright footer, automatically scroll the page down to the work frame, move the control buttons and timer to the header, job control hotkeys, etc.

当前为 2016-03-16 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         CrowdSurfWork productivity extension
// @namespace    mobiusevalon.tibbius.com
// @version      0.3
// @description  Hide the copyright footer, automatically scroll the page down to the work frame, move the control buttons and timer to the header, job control hotkeys, etc.
// @author       Mobius Evalon
// @include      /^https{0,1}:\/\/work\.crowdsurfwork\.com\/tasks\/\w{32}.*?$/
// @grant        none
// ==/UserScript==

function exists(element,tag)
{
	if(element !== null && element !== undefined && (tag === undefined || element.tagName === tag)) return 1;
	return 0;
}

function cspt_message(event)
{
    // this is a hook for keyboard shortcuts from the CrowdSurf Productivity Tools script
    if(event.origin === "https://ops.cielo24.com")
    {
        var data = event.data.split("-");
        if(data[0] === "cspt")
        {
            if(data[1] === "hotkey")
            {
                switch(data[2])
                {
                    case "accept":
                        var accept_button = document.getElementById("accept-button");
                        if(exists(accept_button,"A")) accept_button.click();
                        break;
                    case "return":
                        // handles both return and skip, since both buttons cannot exist at the same time
                        var controls = document.getElementById("task-detail-nav");
                        var skip_button = controls.getElementsByClassName("btn-info")[0];
                        var return_button = controls.getElementsByClassName("btn-danger")[0];
                        if(exists(skip_button,"A") && skip_button.innerHTML.indexOf("Skip") > -1) skip_button.click();
                        else if(exists(return_button,"A") && return_button.innerHTML.indexOf("Return") > -1) return_button.click();
                        break;
                }
            }
        }
    }
}

function ypos(elem)
{
    var y = 0;
    if(elem.offsetParent)
    {
        do y += elem.offsetTop;
        while (elem = elem.offsetParent);
        return y;
    }
}

var header = document.getElementsByClassName("headerwrapper")[0];
var footer = document.getElementsByTagName("footer")[0];
var work_frame = document.getElementById("innerframe");
var task_detail = document.getElementById("task-detail-nav");
var accept_button = document.getElementById("accept-button");
var header_right = header.getElementsByClassName("header-right")[0];
var head = document.getElementsByTagName("head")[0];

var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = "#task-detail-nav {margin: 0px !important; padding: 0px !important; color: #ffffff !important;}"+
    "#task-detail-nav a.btn {margin: 0px 10px !important; padding: 6px 15px !important;}"+
    "#task-detail-nav #Countdown h4 {margin: 0px 10px !important;}";
head.appendChild(css);

footer.style.display = "none"; // takes up unnecessary space and contains nothing but a copyright date

if(exists(accept_button,"A")) // i keep getting these buttons backward because of Turk
{
    var pn = accept_button.parentNode;
    pn.removeChild(accept_button);
    pn.insertBefore(accept_button,pn.childNodes[0]);
}
task_detail.parentNode.removeChild(task_detail);
task_detail.className = "";
header_right.insertBefore(task_detail,header_right.childNodes[0]);

window.scroll(0,ypos(work_frame)-header.scrollHeight+10); // body tag contains 10px of margin by default
window.addEventListener("message",cspt_message,false);