知乎简书网站自动跳转

知乎、简书自动跳转到外部网页

  1. // ==UserScript==
  2. // @name 知乎简书网站自动跳转
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 知乎、简书自动跳转到外部网页
  6. // @author niayyy
  7. // @match https://www.jianshu.com/go-wild*
  8. // @match https://link.zhihu.com/?target=*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let redirectObj = {
  16. jianshu,
  17. zhihu,
  18. }
  19. let href = window.location.href;
  20. let search = window.location.search.slice(1)
  21.  
  22.  
  23. redirectObj[parseHref()]()
  24.  
  25. function parseHref() {
  26. let keys = Object.keys(redirectObj)
  27. for (let i = 0; i < keys.length; i++) {
  28. if(href.includes(keys[i])) {
  29. return keys[i]
  30. }
  31. }
  32. }
  33. function jianshu() {
  34. let arr = search.split('&')
  35. let str = arr.find(p => p.includes('url'))
  36. let url = decodeURIComponent(str.split('=')[1])
  37. open(url, '_self')
  38. }
  39. function zhihu() {
  40. let arr = search.split('&')
  41. let str = arr.find(p => p.includes('target'))
  42. let url = decodeURIComponent(str.split('=')[1])
  43. open(url, '_self')
  44. }
  45. })();

QingJ © 2025

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