Angies_List_Al_Tool_Plugin 1.6

Feng Guan 对Angie's List AL Tool的BPO用户录入操作进行智能优化

目前為 2016-04-08 提交的版本,檢視 最新版本

// ==UserScript==
// @version        2016.04.12
// @name           Angies_List_Al_Tool_Plugin 1.6
// @namespace     AngiesListAlToolPlugin
// @author	      fengguan.ld~gmail。com
// @description    Feng Guan 对Angie's List AL Tool的BPO用户录入操作进行智能优化
// @include        https://altools.angieslist.com/Member/*
//在这写点什么备注信息呢?我还没想好!
// @encoding       utf-8
// @grant          unsafeWindow
// grant          GM_openInTab
// ==/UserScript==
// 
var REQUEST_DELAY = 500; // milliseconds
var LINK_POSITION_OFFSET = 400; // number of pixels abover or below viewport to trigger link check
// remove the // on the next line to enable audio notification
var VOLUME = 0.1; // volume of chime

var audio;
var $preview_links;
var posts_dict = {};
var delay_counter = 0;

function mark_hit_post($link)
{
    $link.text($link.text().replace('[Page Request Rate Error] -- ', ''));
    GM_xmlhttpRequest(
    {
        method: "GET",
        url: $link.attr('href'),
        onerror: function()
        {
            delay_counter--;
            alert('mmmturkeybacon Ghost HIT Buster for Forums: Page request failed.');
        },
        onload: function (response)
        {
            delay_counter--;
            var $src = $(response.responseText);
            var id = $link.closest('div[id^="post_message_"], li[id^="post-"]').attr('id');
            var maxpagerate = $src.find('td[class="error_title"]:contains("You have exceeded the maximum allowed page request rate for this website.")');
            if (maxpagerate.length == 0)
            {
                var is_a_HIT = $src.find('input[type="hidden"][name="isAccepted"]').length > 0;
                var not_qualified = $src.find('span[id="alertboxHeader"]:contains("Your Qualifications do not meet the requirements to preview HITs in this group.")').length > 0;
                var requester_results = $src.find('td[class="title_orange_text_bold"]:contains("HITs Created by")').length > 0;
                if (is_a_HIT)
                {
                    var hitAutoAppDelayInSeconds = $src.find('input[type="hidden"][name="hitAutoAppDelayInSeconds"]').val();
                    var num_available = $src.find('a[id="number_of_hits.tooltip"]').parent().next().text().trim();
        
                    // time formatting code modified from http://userscripts.org/scripts/show/169154
                    var days  = Math.floor((hitAutoAppDelayInSeconds/(60*60*24)));
                    var hours = Math.floor((hitAutoAppDelayInSeconds/(60*60)) % 24);
                    var mins  = Math.floor((hitAutoAppDelayInSeconds/60) % 60);
                    var secs  = hitAutoAppDelayInSeconds % 60;
            
                    var time_str = (days  == 0 ? '' : days  + (days  > 1 ? ' days '    : ' day '))    +
                                   (hours == 0 ? '' : hours + (hours > 1 ? ' hours '   : ' hour '))   + 
                                   (mins  == 0 ? '' : mins  + (mins  > 1 ? ' minutes ' : ' minute ')) + 
                                   (secs  == 0 ? '' : secs  + (secs  > 1 ? ' seconds ' : ' second '));

                    time_str = time_str.replace(/\s+$/, ''); 

                    if (hitAutoAppDelayInSeconds == 0)
                    {
                        time_str = "0 seconds";
                    }
                    $link.text('['+time_str+'|'+num_available+'] -- ' + $link.text());
                    posts_dict[id].link_cnt++;
                    posts_dict[id].strike_all_override = true;
                }
                else if (not_qualified)
                {
                    $link.text('[not qualified] -- ' + $link.text());
                }
                else if (!is_a_HIT && !requester_results)
                {
                    var $hit_container = $link.closest('table[class^="cms_table"], table[class^="ctaBbcodeTable"]');
                    if ($hit_container.length > 0)
                    {
                        $hit_container.css('text-decoration', 'line-through');
                        posts_dict[id].link_cnt++;
                    }
                    else
                    {
                        $link.css('text-decoration', 'line-through');
                        posts_dict[id].link_cnt++;
                        posts_dict[id].strike_all = true;
                    }
                }
            }
            else
            {
                $link.text('[Page Request Rate Error] -- ' + $link.text());
                posts_dict[id].link_cnt++;
                posts_dict[id].strike_all_override = true;
                $link.attr('mtbghbff_checked', 'false');
            }

            if ((posts_dict[id].strike_all_override == false) &&
                (posts_dict[id].strike_all == true) &&
                (posts_dict[id].link_cnt == posts_dict[id].num_links))
            {
                $link.closest('div[id^="'+id+'"], li[id^="'+id+'"]').css('text-decoration', 'line-through');
            }
        }
    });
}

function check_link_position()
{
    $preview_links.each(function()
    {
        var $link = $(this);
        if ($link.attr('mtbghbff_checked') != 'true')
        {
            var link_position = $link.offset().top;
            var top_of_viewport = $(window).scrollTop();
            var bottom_of_viewport = $(window).scrollTop() + $(window).height();

            if(top_of_viewport-LINK_POSITION_OFFSET < link_position && bottom_of_viewport+LINK_POSITION_OFFSET > link_position)
            {
                setTimeout(function(){mark_hit_post($link)}, REQUEST_DELAY*delay_counter);
                $link.attr('mtbghbff_checked', 'true');
                delay_counter++;
            }
        }
    }); 
}

function bustin_makes_me_feel_good()
{
    $preview_links = $('a[href*="/mturk/preview?"][mtbghbff_checked!="true"], a[href*="/mturk/searchbar?"][mtbghbff_checked!="true"]:contains("(Requester link substituted)")');

    if ($preview_links.length > 0)
    {
        var $hit_posts = $('div[id^="post_message_"], li[id^="post-"]').has('a[href*="/mturk/preview?"][mtbghbff_checked!="true"], a[href*="/mturk/searchbar?"][mtbghbff_checked!="true"]:contains("(Requester link substituted)")');

        $hit_posts.each(function()
        {
            var num_links = $(this).find('a[href*="/mturk/preview?"][mtbghbff_checked!="true"], a[href*="/mturk/searchbar?"][mtbghbff_checked!="true"]:contains("(Requester link substituted)")').length;
            posts_dict[$(this).attr('id')] = {num_links: num_links, link_cnt: 0, strike_all: false, strike_all_override: false};
        });

        if (typeof CHIME != 'undefined' && CHIME != '')
        {
            audio.play();
        }

        check_link_position();
    }
}

$(window).load(function()
{//每次刷新页面后都会添加plugbox
	 
		$("#slogan").before('<p id="plugbox" style="z-index: -100; width: 170px; height: 105px; position: fixed; color: royalblue; left: 2px; bottom: 0px; border: 2px solid #b5d4fe; margin: 10px 0 10px 0;"><img title="1.变大categories的checkbox啦; 2.我把Survey评分全都选A啦; 3.自动勾选Agree checkbox啦; 4.Review Origin自动选则MAIL-REVIEW PDF啦; 5. MAIN已经选好DATA TEAM啦; 6. 换行排版神马的最费指甲了点一下就帮你搞定啦; 7. Add Member的Signup Method自动选Non-Member Report啦; 8. Add Member的Source自动选Other啦; 9. 需要其他帮助请找Feng Guan;" src="-" width="160px" height="93px" style="margin:5px 5px 0 0;"/></p>');
	if ($("#plugbox").length==0){} 
	
	//到达Add a Review界面会自动点Service Provider按钮
	if ($("input[ID$='Step2Goto3']").length>0){ 
		$("input[ID$='Step2Goto3']").click();
		//$.cookie('RobotMsg', "."); 
		$("#plugmsg").html("已帮你猛点按钮穿越到下个页面啦");
	} 
	

	/**********************************************************************************************************/
	//以下是ADD A REVIEW页面的优化动作
	/**********************************************************************************************************/
	if($('select[ID$="ReportOriginDropDown"]').length>0){
		//$("#plugmsg").html("<br/>1.变大categories的checkbox.<br/>2.我把Survey评分全都选A啦<br/>3.自动勾选Agree checkbox啦 <br/>4.Review Origin自动选则MAIL - REVIEW PDF啦<br/>5.把俩个评论框瘦身后排排坐啦<br/><br/>* 需要其他帮助请找Feng Guan");
	}
	
	//增大categories的checkbox尺寸
	$('table.cblist [type=checkbox]').attr("style","width:16px;height:16px;").click(function(){
		if($(this).is(':checked')){
			$(this).next().addClass("table-cell-left");
		}
		else{			
			$(this).next().removeClass("table-cell-left");
		}
	});
	//如果一行里已经选了radio就不再替他选第一个radio了,但是实际测试,发现刷新页面后现有表单内容不保留,全部重置,radio全部变为未选中,所以这个判断暂时是多余的
	if($('table[ID$="GradableRadio"]').find("input[type=radio]:checked").length==0){ 
		$('table[ID$="GradableRadio"]').find("td:first").find("input[type=radio]").click();
		//$("#plugmsg").html($("#plugmsg").text()+" Survey评分全都选A啦.");
	}

	//自动选中more information的I confirm that the information contained in this Service Evaluation
	$(":checkbox[ID$=RptIAgree]").attr("checked","checked");
	
	//Review Origin: 下拉,默认选中MAIL - REVIEW PDF选项,此项的VALUE=49
	$('select[ID$="ReportOriginDropDown"]').find("option[value=49]").attr("selected","selected");
	
	//对俩评论文本框重新摆放,一左一右,因为原来一上一下的太费空间	
	//$("span[ID$=WorkDescLabel]").parent().wrap('<td id="tdWorkDescLabel" valign="top" style="height:200px;"></td>');
	//$("span[ID$=CommentLabel]").parent().wrap('<td id="tdCommentLabel" valign="top" style="height:200px;"></td>');
	//$("#tdWorkDescLabel").wrap('<table><tr id="trCommentLabel"></tr></table>');
	//$("#tdCommentLabel").insertAfter("#tdWorkDescLabel").find("br").remove();	
	//对俩评论文本框进行宽高瘦身
	$("div[ID$=ReportTextWorkDescriptionRadEditor]").css({"height":"150px","min-height":"220px","width":"450px"});
	$("table[ID$=ReportTextWorkDescriptionRadEditorWrapper]").css("height","120px");
	$("div[ID$=ReportTextCommentsRadEditor]").css({"height":"150px","min-height":"220px","width":"450px"});
	$("table[ID$=ReportTextCommentsRadEditorWrapper]").css("height","120px");
	$("span.exceptionlanguage").hide();
	$("span.exceptionlanguage").parent().attr("style",""); //You have 10000 characters remaining.取消居右显示
	
	//这个SPAN的文字太长,挤到右边的评论框,缩减文件,增加提示
	$("span[ID$=WorkDescLabel]").text("Please describe the reason for your appointment(10000 char remaining)").attr("title","Please describe the reason for your appointment, your interaction with the provider, and any treatment outcomes.");
	$("span[ID$=CommentLabel]").text("How'd it go? We want all the details.(10000 char remaining)");
	
	/**********************************************************************************************************/
	//以下是Add Notes页面的优化动作
	/**********************************************************************************************************/
	if($("textarea[ID$=AddNoteTextBox]")){
		//$("#plugmsg").html("1. MAIN已经选好DATA TEAM啦!<br/>2. SUB下面打酱油的家伙们去火星了<br/>3. 换行排版神马的最费指甲了<br/>点一下就帮你搞定啦!<br/>* 需要其他帮助请找Feng Guan");
	}
	
	//MAIN:自动选择第14项 DATA TEAM
	$('select[ID$="MainNoteCategoryDropDown"]').find("option[value=14]").attr("selected","selected");
	 $('select[ID$="MainNoteCategoryDropDown"] option').each(function (){  
       var txt = $(this).text();  
       if(txt!="DATA TEAM" || txt!="Select a Type"){  
          $(this).remove(); 
       }  
     });

	   //("select[ID$=SubNoteCategoryDropDown]").empty(); //用脚本附加的选项无法提交
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option selected="selected" value="0">Select a Type</option>');  
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option value="6580">Paper Report - Not Entered</option>'); 
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option value="5203">Non-Member Report Entered - Paper</option>');  
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option value="616">Send Info Created - Review Entered</option>');  
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option value="5199">Send Info Created - Missing Report Info</option>');  
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option value="5220">Free Member Created – Report Not Entered</option>');  
		//$("select[ID$=SubNoteCategoryDropDown]").append('<option value="5211">Free Member Created – Report Entered</option>');  

	//点击鼠标为NOTES textarea自动排版
	$("textarea[ID$=AddNoteTextBox]").click(function(){			
		var txtnote=$.trim($("textarea[ID$=AddNoteTextBox]").val());
		txtnote = txtnote.replace(/[\r\n]/g," ")//去掉回车换行,多行变一行 
		if(txtnote!="" && txtnote.substr(0,23)!="Entered paper review on"){
			txtnote="Entered paper review on "+ txtnote; //起头加固定句式
		}			
		var juhao=txtnote.substr(txtnote.length-1,1);
		if(txtnote!="" && juhao!="."){ //末尾加句号
			txtnote=txtnote+".";
		}
		while (txtnote.indexOf("  ")>0) //去掉多位空格
	   {
			txtnote=txtnote.replace("  "," ");
	   }
		
		$("textarea[ID$=AddNoteTextBox]").val(txtnote);
	});

	/**********************************************************************************************************/
	//以下是Add a member 页面的优化动作
	/**********************************************************************************************************/
	$("#lcontentsalesCall").css("margin-left","220px");//往右让220给小叮当点地方啊
	//What is the Signup Method? 自动选择value=23的Non-member Report项
	$('select[ID$="SignupDropDown"]').find("option[value=23]").attr("selected","selected");
	 $('select[ID$="SignupDropDown"] option').each(function (){  
       var txt = $(this).text();  
       if(txt!="Non-Member Report"){  
          $(this).remove(); 
       }  
     });
	//Source自动选择value=7的Other项
	$('select[ID$="sourceDDList"]').find("option[value=7]").attr("selected","selected");
	$('select[ID$="sourceDDList"] option').each(function (){  
       var txt = $(this).text();  
       if(txt!="Other"){  
          $(this).remove(); 
       }  
     });
	//$(".VealColumnLabel,.dropdown,.button,input").css("font-size","16px");
   //$("#MemberInfoDiv").css("width","800px");

	 var observer = new MutationObserver(function(mutations, obs)
    {
        var new_links_available = false;
        for(var i = 0; i < mutations.length; i++)
        {
            for(var j = 0; j < mutations[i].addedNodes.length; j++)
            {
                var new_tag = mutations[i].addedNodes[j];
                if ($(new_tag).find('a[href*="/mturk/preview?"][mtbghbff_checked!="true"], a[href*="/mturk/searchbar?"][mtbghbff_checked!="true"]:contains("(Requester link substituted)")').length > 0)
                {
                    new_links_available = true;
                    break;
                }
            }
            if (new_links_available)
            {
                break;
            }
        }

        if (new_links_available)
        {
            bustin_makes_me_feel_good();
        }
    });

    observer.observe(document.documentElement,
    {
        childList: true,
        subtree: true
    });
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址