[user] to OP's name on StackExchange sites

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

目前為 2018-10-15 提交的版本,檢視 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址