巴哈瀏覽作者同版發文

在巴哈右鍵點擊發文者連結,瀏覽作者同版發文

  1. // ==UserScript==
  2. // @name 巴哈瀏覽作者同版發文
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 在巴哈右鍵點擊發文者連結,瀏覽作者同版發文
  6. // @author Rplus
  7. // @match https://m.gamer.com.tw/forum/*.php?*
  8. // @match https://forum.gamer.com.tw/*.php*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. let isMobile = !/forum/.test(location.host);
  14. let bsn = new URLSearchParams(location.search)?.get('bsn');
  15. function getUid(a) {
  16. if (!a) { return false; }
  17.  
  18. if (isMobile) {
  19. // https://m.gamer.com.tw/home/home.php?owner=***
  20. return (new URLSearchParams(a.search))?.get('owner');
  21. } else {
  22. // .userid
  23. // .username
  24. // .reply-content__user
  25. // https://home.gamer.com.tw/***
  26. if (a.matches('.userid, .username, .reply-content__user')) {
  27. return a.href.replace('https://home.gamer.com.tw/', '');
  28. }
  29. return false;
  30. }
  31. }
  32.  
  33. document.body.addEventListener('contextmenu', e => {
  34. let a = e.target.closest('a');
  35. let uid = getUid(a);
  36. if (bsn && uid) {
  37. const url = `https://forum.gamer.com.tw/Bo.php?bsn=${bsn}&qt=6&q=${uid}`;
  38. const ans = window.confirm(`Go to ${url}?`);
  39. if (ans) {
  40. e.preventDefault();
  41. window.open(url, null, 'noopener,noreferrer');
  42. }
  43. }
  44. })
  45. })();

QingJ © 2025

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