V2EX Domain Switcher

尽可能避免增加账号的活跃度 (已弃用)

  1. // ==UserScript==
  2. // @name V2EX Domain Switcher
  3. // @version 1.1
  4. // @description 尽可能避免增加账号的活跃度 (已弃用)
  5. // @match *://*.v2ex.com/*
  6. // @match *://*.v2ex.co/*
  7. // @author Wanten
  8. // @copyright 2024 Wanten
  9. // @license MIT
  10. // @supportURL https://github.com/WantenMN/v2ex-userscripts/issues
  11. // @icon https://v2ex.com/favicon.ico
  12. // @homepageURL https://github.com/WantenMN/v2ex-userscripts
  13. // @namespace https://gf.qytechs.cn/en/scripts/509836
  14. // @run-at document-end
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. (function () {
  19. "use strict";
  20.  
  21. // Create floating button
  22. const button = document.createElement("button");
  23. button.style.position = "fixed";
  24. button.style.bottom = "20px";
  25. button.style.right = "20px";
  26. button.style.padding = "7px";
  27. button.style.border = "black 2px solid";
  28. button.style.borderRadius = "25px";
  29. button.style.cursor = "pointer";
  30.  
  31. // Function to get clean domain (without www)
  32. function getCleanDomain(domain) {
  33. return domain.replace(/^www\./, "");
  34. }
  35.  
  36. // Set button color and border based on current clean domain
  37. const currentCleanDomain = getCleanDomain(window.location.hostname);
  38. if (currentCleanDomain === "v2ex.com") {
  39. button.style.backgroundColor = "green";
  40. button.style.border = "2px solid darkgreen"; // Border color for green
  41. } else if (currentCleanDomain === "global.v2ex.co") {
  42. button.style.backgroundColor = "yellow";
  43. button.style.border = "2px solid darkorange"; // Border color for yellow
  44. }
  45.  
  46. // Add click event listener
  47. button.addEventListener("click", () => {
  48. const newDomain =
  49. currentCleanDomain === "v2ex.com" ? "global.v2ex.co" : "v2ex.com";
  50. const newUrl = new URL(window.location.href);
  51. newUrl.hostname = newDomain;
  52. window.location.href = newUrl.toString();
  53. });
  54.  
  55. // Add button to page
  56. document.body.appendChild(button);
  57. })();

QingJ © 2025

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