mmmturkeybacon Show Only HIT Posts

Show only posts that contain links to mturk.

目前為 2015-04-01 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        mmmturkeybacon Show Only HIT Posts
// @version     1.12
// @description Show only posts that contain links to mturk.
// @author      mmmturkeybacon
// @namespace   http://userscripts.org/users/523367
// @match       http://mturkgrind.com/threads/*
// @match       http://www.mturkgrind.com/threads/*
// @match       http://mturkgrind.com/showthread.php?*
// @match       http://www.mturkgrind.com/showthread.php?*
// @match       http://mturkforum.com/showthread.php?*
// @match       http://www.mturkforum.com/showthread.php?*
// @exclude     http://mturkgrind.com/threads/*#post*
// @exclude     http://www.mturkgrind.com/threads/*#post*
// @exclude     http://mturkgrind.com/showthread.php?*post*
// @exclude     http://www.mturkgrind.com/showthread.php?*post*
// @exclude     http://mturkforum.com/showthread.php?*post*
// @exclude     http://www.mturkforum.com/showthread.php?*post*
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_log
// ==/UserScript==

var original_elements = new Array();
var butterbean_elements = new Array();

function butterbean_setup()
{
    $('img[src^="data/avatars"]').each(function()
    {
        var $this = $(this);
        original_elements.push($this);
        var $clone = $this.clone();
        $clone.attr('src', 'https://www.mturk.com/media/butterbean.jpg');
        $clone.css('display', 'none');
        $this.after($clone);
        butterbean_elements.push($clone);
    });

    $('a[href^="members/"][class^="username"] > span').each(function()
    {
        var $this = $(this);
        original_elements.push($this);
        var $clone = $this.clone();
        $clone.html('butterbean');
        $clone.css('display', 'none');
        $this.after($clone);
        butterbean_elements.push($clone);
    });

    $('div[class="attribution type"]').each(function()
    {
        var $this = $(this);
        original_elements.push($this);

        var name = $this.text().split(' said:')[0];
        var html = $this.html();
        html = html.replace(name, 'butterbean');

        var $clone = $this.clone();
        $clone.html(html);
        $clone.css('display', 'none');
        $this.after($clone);
        butterbean_elements.push($clone);
    });

    $('a[href^="members/"][class="username author"]').each(function()
    {
        var $this = $(this);
        original_elements.push($this);
        var $clone = $this.clone();
        $clone.html('butterbean');
        $clone.css('display', 'none');
        $this.after($clone);
        butterbean_elements.push($clone);
    });

    //setTimeout(function(){butterbean()}, 500);
}

function butterbean()
{
    $('body').attr('background', 'https://www.mturk.com/media/butterbean.jpg');
    $('div[id="headerMover"]').css('opacity', '0.85');

    for (var i = 0; i < original_elements.length; i++)
    {
        original_elements[i].hide();
        butterbean_elements[i].show();
    }
    //setTimeout(function(){unbutterbean()}, 0);
}

function unbutterbean()
{
    $('body').attr('background', '');
    $('div[id="headerMover"]').css('opacity', '1.0');

    for (var i = 0; i < original_elements.length; i++)
    {
        original_elements[i].show();
        butterbean_elements[i].hide();
    }
    //setTimeout(function(){butterbean()}, 10000);
}


$(document).ready(function()
{
    //setTimeout(function(){butterbean_setup()}, 10000);
    butterbean_setup();

    function toggle_hidden()
    {
        if (toggle_button.textContent == "Show Only HITs")
        {
            toggle_button.textContent = "Show All Posts";
            GM_setValue("toggle_button.textContent", "Show All Posts");

            butterbean();
            show_only_hits();
        }
        else if(toggle_button.textContent == "Show All Posts")
        {
            toggle_button.textContent = "Show Only HITs";
            GM_setValue("toggle_button.textContent", "Show Only HITs");

            unbutterbean();
            $('li[id^="post_"], li[id^="post-"][hidden_post="true"]').not('li[id^="post_thanks_box_"], li[id^="likes-post"]').each(function()
            {
                $(this).show();
                $(this).next('li[id^="post_thanks_box_"], li[id^="likes-post"][hidden_post="true"]').show();
            });

        }
    }

    function show_only_hits()
    {
        //$('li[id^="post_"]').not('li[id^="post_thanks_box_"]').each(function()
        $('li[id^="post_"], li[id^="post-"]').not('li[id^="post_thanks_box_"], li[id^="likes-post"]').each(function()
        {
            if ($(this).find('a[href^="https://www.mturk.com/mturk/preview"]').length == 0)
            {
                $(this).hide();
                $(this).attr("hidden_post", "true");
                var $thanks = $(this).next('li[id^="post_thanks_box_"], li[id^="likes-post"][style!="display:none"]');
                $thanks.hide();
                $thanks.attr("hidden_post", "true");
            }
        });
    }

    var button_holder = document.createElement("DIV");
    button_holder.style = "position: fixed; top: 10px; left: 10px; z-index: 1";
    var toggle_button = document.createElement("BUTTON");
    toggle_button.textContent = GM_getValue("toggle_button.textContent", "Show Only HITs");
    toggle_button.onclick = function(){toggle_hidden();};
 
    if (toggle_button.textContent == "Show All Posts")
    {
        butterbean();
        show_only_hits();
    }
 
    document.body.insertBefore(button_holder, document.body.firstChild);
    button_holder.appendChild(toggle_button);
});