[user] to OP's name on StackExchange sites

Changes [user] to the OP's username when commenting on StackExchange sites

16.10.2018 itibariyledir. En son verisyonu görün.

  1. // ==UserScript==
  2. // @name [user] to OP's name on StackExchange sites
  3. // @namespace https://zachsaucier.com/
  4. // @version 0.5
  5. // @description Changes [user] to the OP's username when commenting on StackExchange sites
  6. // @author Zach Saucier
  7. // @match https://*.stackexchange.com/*
  8. // @match https://*.stackoverflow.com/*
  9. // @match https://stackoverflow.com/*
  10. // @match https://*.meta.stackoverflow.com/*
  11. // @match https://meta.stackoverflow.com/*
  12. // @match https://superuser.com/*
  13. // @match https://meta.superuser.com/*
  14. // @match https://askubuntu.com/*
  15. // @match https://meta.askubuntu.com/*
  16. // @match https://serverfault.com/*
  17. // @match https://meta.serverfault.com/*
  18. // @match https://mathoverflow.net/*
  19. // @match https://meta.mathoverflow.net/*
  20. // @match https://stackapps.com/*
  21. // @match https://meta.stackapps.com/*
  22. // @exclude https://chat.stackexchange.com/*
  23. // @exclude https://chat.stackoverflow.com/*
  24. // @grant none
  25. // ==/UserScript==
  26.  
  27. (function() {
  28. 'use strict';
  29.  
  30. document.body.addEventListener("keyup", (e) => {
  31. let elem = e.target,
  32. opName = "[user]";
  33.  
  34. if(document.querySelector(".owner .user-details a")) {
  35. opName = document.querySelector(".owner .user-details a").innerText;
  36. }
  37.  
  38. if(elem.name === "comment") {
  39. elem.value = elem.value.replace(/\[user\]/g, opName);
  40. }
  41. });
  42. })();