StackExchange Link Personalizer

Personalizes links to questions with your userID for sharing and collecting (Announcer/Booster/Publicist) badges

  1. // ==UserScript==
  2. // @id izzysoft_SELP
  3. // @name StackExchange Link Personalizer
  4. // @version 1.4
  5. // @namespace http://projects.izzysoft.de/
  6. // @author IzzySoft
  7. // @description Personalizes links to questions with your userID for sharing and collecting (Announcer/Booster/Publicist) badges
  8. // @license CC BY-NC-SA
  9. // @include http*://*.stackexchange.com/*
  10. // @include http*://askubuntu.com/*
  11. // @include http*://mathoverflow.net/*
  12. // @include http*://serverfault.com/*
  13. // @include http*://stackapps.com/*
  14. // @include http*://stackoverflow.com/*
  15. // @include http*://meta.stackoverflow.com/*
  16. // @include http*://superuser.com/*
  17. // @grant none
  18. // @run-at document-end
  19. // ==/UserScript==
  20. var skipClasses = ['flag-post-link','close-question-link','edit-post','comments-link '];
  21.  
  22. if ( document.getElementsByClassName('my-profile')[0].href.match(/\/users\/(\d+)\/.*/i) ) {
  23. var user_id = RegExp.$1;
  24.  
  25. for(var i = 0; i < document.links.length; i++) {
  26. var elem = document.links[i];
  27. if ( skipClasses.indexOf(elem.className) != -1 ) continue;
  28. if ( elem.hostname != document.location.hostname ) continue;
  29. if ( elem.href.match(/\/questions\/(\d+)\/.*(\?.+#.+)/i) ) {
  30. null; // doesn't work with replaced URL here for some reason
  31. } else if ( elem.href.match(/\/questions\/(\d+)\/.*(#.+)/i) ) {
  32. elem.href='/q/'+RegExp.$1+'/'+user_id+RegExp.$2;
  33. } else if ( elem.href.match(/\/questions\/(\d+)\/.*/i) ) {
  34. elem.href='/q/'+RegExp.$1+'/'+user_id;
  35. }
  36. }
  37. }