Waze Editor Profile Enhancements

Enhances the Editor Profile with such features as - pulling the correct forum post count & adding a Forum Profile button

目前為 2017-03-10 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Waze Editor Profile Enhancements
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Enhances the Editor Profile with such features as - pulling the correct forum post count & adding a Forum Profile button
  6. // @author JustinS83
  7. // @include https://www.waze.com/user/editor*
  8. // @grant GM_xmlhttpRequest
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function bootstrap(tries) {
  15. tries = tries || 1;
  16.  
  17. if (W &&
  18. W.EditorProfile &&
  19. $) {
  20. init();
  21. } else if (tries < 1000) {
  22. console.log(tries);
  23. setTimeout(function () {bootstrap(tries++);}, 200);
  24. }
  25. }
  26.  
  27. bootstrap();
  28.  
  29. function init(){
  30. $.get('https://www.waze.com/forum/memberlist.php?username=' + W.EditorProfile.data.username, function(forumResult){
  31. var re = forumResult.match(/<a.*?"Search user’s posts">(\d+)<\/a>/)[1];
  32. var WazeVal = $('#header > div > div.user-info > div > div.user-highlights > div > div:nth-child(3) > div.user-stats-value')[0].innerHTML.trim();
  33. var userForumID = forumResult.match(/<a href="\.\/memberlist\.php\?mode=viewprofile&amp;u=(\d+)"/)[1];
  34.  
  35. $('#header > div > div.user-info > div > div.user-highlights > div > div:nth-child(3) > div.highlight-title').css('position', 'relative');
  36.  
  37. if(WazeVal !== re){
  38. $('#header > div > div.user-info > div > div.user-highlights > div > div:nth-child(3) > div.user-stats-value')[0].innerHTML = re;
  39. $('#header > div > div.user-info > div > div.user-highlights > div > div:nth-child(3) > div.user-stats-value').css('color','red');
  40. $('#header > div > div.user-info > div > div.user-highlights > div > div:nth-child(3) > div.user-stats-value').prop('title', 'Waze reported value: ' + WazeVal);
  41. }
  42.  
  43. $('#header > div > div.user-info > div > div.user-highlights > div > div:nth-child(3)').wrap('<a href="https://www.waze.com/forum/search.php?author_id=' + userForumID + '&sr=posts" targ="_blank"></a>');
  44.  
  45. $('#header > div > div.user-info > div > div.user-highlights > a').prepend('<a href="https://www.waze.com/forum/memberlist.php?mode=viewprofile&u=' + userForumID +'" target="_blank" style="margin-right:5px;"><button class="message s-modern-button s-modern"><i class="fa fa-user"></i><span>Forum Profile</span></button></a>');
  46. });
  47. }
  48. })();