This script is for replying to UR comments with a single click. Based off Chat Jumper and URO+
当前为
// ==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.1 // @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.1 - 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 uroTimbonesGetElementsByClassName(classname, node) { if(!node) node = document.getElementsByTagName("body")[0]; var a = []; var re = new RegExp('\\b' + classname + '\\b'); var els = node.getElementsByTagName("*"); for (var i=0,j=els.length; i<j; i++) if (re.test(els[i].className)) a.push(els[i]); return a; } 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>'); $(".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>'); 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>'); 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>'); 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>'); 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();