NGA_parse_uid

在未登录(不可用)/实名NGA时解析uid为用户名

  1. // ==UserScript==
  2. // @name NGA_parse_uid
  3. // @version 1.2.1
  4. // @author Inazuma
  5. // @match https://nga.178.com/*
  6. // @match https://bbs.ngacn.cc/*
  7. // @match https://bbs.nga.cn/*
  8. // @match http://nga.178.com/*
  9. // @match http://bbs.nga.cn/*
  10. // @match http://bbs.ngacn.cc/*
  11. // @namespace https://gf.qytechs.cn/users/163468
  12. // @description 在未登录(不可用)/实名NGA时解析uid为用户名
  13. // @grant GM_getValue
  14. // @grant GM_setValue
  15. // ==/UserScript==
  16.  
  17. const replaceUID = async () => {
  18. const pattern = 'nuke.php?func=ucp&uid=';
  19. const uidMap = JSON.parse(await GM_getValue('uidMap', '{}'));
  20. [...document.querySelectorAll(`a[href*="${pattern}"]`)].map((v, i) => {
  21. const uid = v.href.split(pattern)[1];
  22. if (!uidMap[uid]) {
  23. if (v.parentNode.className === 'quote') {
  24. uidMap[uid] = v.innerText.slice(1, -1);
  25. } else if (v.parentNode.className === 'c3' && !v.querySelector('span[class="b silver"]')) {
  26. uidMap[uid] = v.innerText;
  27. }
  28. } else {
  29. v.innerText = uidMap[uid];
  30. }
  31. });
  32. await GM_setValue('uidMap', JSON.stringify(uidMap));
  33. }
  34.  
  35. (async () => {
  36. await replaceUID();
  37.  
  38. if (unsafeWindow.commonui) {
  39. const f = unsafeWindow.commonui.progbar;
  40. unsafeWindow.commonui.progbar = async (...args) => {
  41. f(...args);
  42. await replaceUID();
  43. }
  44. }
  45.  
  46. [...document.querySelectorAll('a[href="被禁止的链接"]')].map((v, i) => {
  47. let link;
  48. if (v.parentNode.className !== 'nobr') {
  49. link = v.previousElementSibling.firstChild.innerText.replace(/<[^>]+>/g, '');
  50. v.setAttribute('href', link);
  51. v.innerText = v.innerText.replace(/被禁止的链接/g, link);
  52. } else {
  53. link = v.parentNode.parentNode.firstChild.innerText.replace(/<[^>]+>/g, '');
  54. v.setAttribute('href', link);
  55. }
  56. });
  57.  
  58. })();

QingJ © 2025

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