WME RickZabelComments

This script is for replying to UR comments with a single click. Based off Chat Jumper and URO+

当前为 2014-10-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name			WME RickZabelComments
// @description		This script is for replying to UR comments with a single click. Based off Chat Jumper and URO+
// @namespace		[email protected]
// @grant			none
// @grant			GM_info
// @version			0.0.2
// @match			https://editor-beta.waze.com/*editor/*
// @match			https://www.waze.com/*editor/*
// @author			Rick Zabel '2014
// @license			MIT/BSD/X11
// ==/UserScript==


/* Changelog
 change 
 * 0.0.2 - initial version
 */


function RickZabelComments_bootstrap() {
    var bGreasemonkeyServiceDefined = false;
    
    try {
        var ver = window.navigator.appVersion.match(/Chrome\/(.*?) /)[1];
    } catch(err) {
        var ver = null;
    }
    if (null !== ver) {
        var itschrome = true;
        ///ver = "27.0.1438.7"; // last old working version
        // example: 32.0.1700.107
        // [0] - major versin
        // [2] - minor version
        ver = ver.split(".");
        ver[0] = parseInt(ver[0]);
        ver[2] = parseInt(ver[2]);
        if (ver[0] > 27) {
            var newmethod = true;
        } else if (ver[0] == 27) {
            if (ver[2] <= 1438) {
                var newmethod = false;
            } else {
                var newmethod = true;
            }
        } else {
            var newmethod = false;	
        }
    } else {
        var itschrome = false;
        var newmethod = false;
    }
    
    try {
        if ("object" === typeof Components.interfaces.gmIGreasemonkeyService)  // Firefox tells that "Components" is deprecated
        {
            bGreasemonkeyServiceDefined = true;
        }
    }	catch (err) { };
    
    try
    {
        if  ("object" === typeof GM_info) 
        {
            bGreasemonkeyServiceDefined = true;
        }
    }	catch (err) { };   
    
    
    if ( "undefined" === typeof unsafeWindow  ||  ! bGreasemonkeyServiceDefined)
    {
        try {
            unsafeWindow    = ( function ()
                               {
                                   var dummyElem   = document.createElement('p');
                                   dummyElem.setAttribute ('onclick', 'return window;');
                                   return dummyElem.onclick ();
                               } ) ();
        } 
        catch (err)
        {
            //Ignore.
        }
    }
    
    /* FIX IT !!!! */
    var itschrome = true;
    var newmethod = true;
    var bGreasemonkeyServiceDefined = false;
    
    //And check again for new chrome, and no tamper(grease)monkey
    if ( itschrome && newmethod &&  !bGreasemonkeyServiceDefined)
    {
        //use "dirty" but effective method with injection to document
        var DLscript = document.createElement("script");
        DLscript.textContent ='unsafeWindow=window; \n'+ // need this for compatibility
            RickZabelComments_init.toString()+' \n'+
            'RickZabelComments_init();';
        DLscript.setAttribute("type", "application/javascript");
        document.body.appendChild(DLscript);    
        document.body.removeChild(DLscript); 
    } else {
        /* begin running the code! */
        console.log("RickZabelComments end of boot strap");      
        RickZabelComments_init(); 
        ///setTimeout(RickZabelComments_init,200);
    } 
}

function RickZabelComments_init() {
    
    RickZabelComments =  { 
        last: new Array(),
        isLast: false,
        isLSsupported: false,
        zoom: false
    };
    
    RickZabelComments.init = function() {
        
        console.log("RickZabelComments init");
        
        //add comments tab
        var b = $('<li> <a data-toggle="tab" href="#sidepanel-Comments">Comments</a> </li> ');
        $(".nav-tabs").append(b);
        
        
        //add content to the comments tab
        
        //Comment tab header
        var c = $('<div class="tab-pane" id="sidepanel-Comments"> <div class="result-list-container"><p class="message"><b>This script is for replying to UR comments with a single click.</b></p></div></div><br><br>');
        $(".tab-content").append(c);
        
        //Errors
        var d = $('<div><a id="RickZabelComments-comment1" class="RickZabelComments" style="float:none;color:#000000" title="comment2" type="button">Errors with no descriptive text</a></div><br>');  
        d.click (RickZabelComments.comment1);
        $("#sidepanel-Comments").append(d);
        
        //4 day Follow-Up
        var  e = $('<div><a id="RickZabelComments-comment2" class="RickZabelComments" style="float:none;color:#000000" title="comment2" type="button">4 day Follow-Up</a></div><br>');  
        e.click (RickZabelComments.comment2);
        $("#sidepanel-Comments").append(e);
        
        
        //7th day No Response/Close
        var e = $('<div><a id="RickZabelComments-comment3" class="RickZabelComments" style="float:none;color:#000000" title="comment2" type="button">7th day No Response/Close</a></div><br>');  
        e.click (RickZabelComments.comment3);
        $("#sidepanel-Comments").append(e);      
        
        
        //Fixed
        var e = $('<div><a id="RickZabelComments-comment4" class="RickZabelComments" style="float:none;color:#000000;" title="comment2" type="button">Fixed</a></div><br>');  
        e.click (RickZabelComments.comment4);
        $("#sidepanel-Comments").append(e);           
        
        
        console.log("RickZabelComments Tab Added");
        
    }                    
    
    
    RickZabelComments.comment1 = function() {
        console.log("RickZabelComments comment1");
        
        if ($(".new-comment-text")[0]){  
            
            //Errors.
            var content = "Can you provide more information about the problem you reported here?";
            $(".new-comment-text").val(content);
        } else {
            alert("Can not find the comment box!");
        }
        
    }   
    
    RickZabelComments.comment2 = function() {
        console.log("RickZabelComments comment2")
        if ($(".new-comment-text")[0]){  
            
            //Follow-Up
            var content = "Just a reminder: We haven't received a response on your report. If we don't hear back from you we'll have to infer everything is okay and close the report. Thanks";
            
            $(".new-comment-text").val(content);
        } else {
            alert("Can not find the comment box!");
        }
        
    }
    
    
    RickZabelComments.comment3 = function() {
        console.log("RickZabelComments comment3")
        if ($(".new-comment-text")[0]){  
            
            //Follow-Up - No Response/Closed
            var content = "The problem was unclear and volunteers didn't receive a response. As you travel, please feel welcome to report any map issues you encounter. Thanks";
            
            $(".new-comment-text").val(content);
        } else {
            alert("Can not find the comment box!");
        }
        
    }
    
    RickZabelComments.comment4 = function() {
        console.log("RickZabelComments comment4")
        if ($(".new-comment-text")[0]){  
            
            //Fixed
            var content = "Thanks to your report we've found and fixed a problem with the map. The fix should reach handheld devices within a week, but on rare occasions it can take closer to two weeks.";
            
            $(".new-comment-text").val(content);
        } else {
            alert("Can not find the comment box!");
        }
        
    }
    
    
    
    RickZabelComments.startcode = function () {
        
        
        // Check if WME is loaded, if not, waiting a moment and checks again. if yes init RickZabelComments
        try {
            if ("undefined" != typeof unsafeWindow.W.model.chat.rooms._events.listeners.add[0].obj.userPresenters[unsafeWindow.Waze.model.loginManager.user.id] ) {
                //check for the comment area
                //  if ($(".new-comment-text")[0]){  
                //console.log("RickZabelComments To Add Comment Tab");
                RickZabelComments.init()
            } else {
                setTimeout(RickZabelComments.startcode, 200);
            }
        } catch(err) {
            setTimeout(RickZabelComments.startcode, 200);
        }
        
    }
    
    ///setTimeout(RickZabelComments.startcode, 5000);
    RickZabelComments.startcode();
}
setTimeout(RickZabelComments_bootstrap(), 5000);
//RickZabelComments_bootstrap();