您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Splice and Modify of CH MTurk Page Titles and mTurk Title Bar Timer
当前为
// ==UserScript== // @name AMT Titles // @author xorith // @namespace xorith // @description Splice and Modify of CH MTurk Page Titles and mTurk Title Bar Timer // @version 1.0.1 // @match http://www.mturk.com/* // @match https://www.mturk.com/* // @require http://code.jquery.com/jquery-latest.min.js // @grant GM_log // ==/UserScript== // I've eliminated the prefix to page titles from CH MTurk Page Titles, as to make them easier to read. // I've also removed many of the page titles from the original script. I will be adding them back in as I // continue to modify this. I've also added the code from mTurk Title Bar Timer and modified it to flow // better. (It no longer shows 0's for days and hours). My goal is to build a customizable title mod // out of all this. -- Xorith // get URL variable - from http://css-tricks.com/snippets/javascript/get-url-variables/ function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for ( var i=0; i<vars.length; i++ ) { var pair = vars[i].split("="); if ( pair[0] == variable ) { return pair[1]; } } return(false); } // append heading-esque text from page content: // for URL used by https://greasyfork.org/scripts/2002-hit-scraper-with-export if ( document.location.href.indexOf('hit_scraper') > -1 ) { document.title = "AMT - HIT Scraper"; } // Special for dashboard else if ( document.location.href.indexOf('dashboard') > -1 ) { document.title = "AMT - Dashboard"; } // Special for "Your HITs" else if ( document.location.href.indexOf('myhits') > -1 ) { document.title = "AMT - My HITs"; } // Removed search titles. // individual HIT/qual pages else if ( $('td.capsulelink_bold').text().trim() !== "" ) { if ( $('td.capsule_field_text').first().text().trim() !== "" ) { // qual page if ( document.location.href.indexOf('qualification') > -1 ) { document.title = "Qual by " + $('td.capsule_field_text').first().text().trim() + " - " + $('td.capsulelink_bold').text().trim(); } // HIT page else { // captcha-ed HIT if ( $('a[class="whatis"][href*="whatAreCaptchas"]').text().trim() !== "" ) { document.title = "!!!CAPTCHA!!! [" + $('td.capsulelink_bold').text().trim() + "] [" + $('td.capsule_field_text').first().text().trim() + "]"; } // accepted HIT (Note: Timer will be in front) else if ( $('a[href*="mturk/return"]').length > 0 ) { document.title = "[" + $('td.capsulelink_bold').text().trim() + "] [" + $('td.capsule_field_text').first().text().trim() + "]"; } // regular preview page else { document.title = "Viewing [" + $('td.capsulelink_bold').text().trim() + "] [" + $('td.capsule_field_text').first().text().trim() + "]"; } } } else { document.title = $('td.capsulelink_bold').text().trim(); } } // contact pages else if ( $('div.contactus form p').first().text().trim() !== "" ) { // contact requester pages if ( document.location.href.indexOf('requesterId=') > -1 ) { document.title = $('div.contactus form p').first().text().trim() + " (" + getQueryVariable("requesterId") + ")"; // add requester ID to in-page heading text too if ( getQueryVariable("requesterName") ) { $('div.contactus form p').first().text("Contact Requester: " + decodeURIComponent( getQueryVariable("requesterName").replace(/\+/g, " ") ) + " (" + getQueryVariable("requesterId") + ")" ); } // replace confusing 'Contact Requester "" ' line with a statement of the ID when there's no name provided in the URL to use else { $('div.contactus form p').first().text("Contact Requester ID: " + getQueryVariable("requesterId") ); } } // contact mturk page else { document.title = $('div.contactus form p').first().text().trim(); } } // status/earnings pages else if ( $('td.white_text_14_bold').text().trim() !== "" ) { document.title = "AMT - " + $('td.white_text_14_bold').contents().filter(function(){return this.nodeType == 3;})[0].nodeValue.trim(); // exclude text inside another layer of nested tags such as 'a' or 'span' } // Timer Code - After we build the new title var original_title = document.title; var st = unsafeWindow.serverTimestamp; var et = unsafeWindow.endTime; var timer_id; var offset; if (st && et) { timer_id = setInterval(function() { if (!offset) { offset = (new Date()).getTime() - st; } var left = Math.floor((et.getTime() - (new Date()).getTime() + offset) / 1000); var days = Math.floor(left / (86400)); var hours = Math.floor(left / 3600) % 24; var mins = Math.floor(left / 60) % 60; var secs = left % 60; document.title = "[" + (days === 0 ? "" : days + ":") + (hours === 0 ? "" : hours + ":") + ("0" +mins).slice(-2) + ":" + ("0" +secs).slice(-2) + "] " + original_title; // document.title = "[" + days + ":" + hours + ":" + ("0" +mins).slice(-2) + ":" + ("0" +secs).slice(-2) + "] " + original_title; }, 1000); }