Fuck Wechat or zhihu

自动重定向被微信/知乎拦截的链接

  1. // ==UserScript==
  2. // @name Fuck Wechat or zhihu
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 自动重定向被微信/知乎拦截的链接
  6. // @author zheng-kun@foxmail.com
  7. // @match *://weixin110.qq.com/*
  8. // @match *://link.zhihu.com/*
  9. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. //setTimeout(redirect, 1000)
  17. redirect()
  18.  
  19. function getUrl(){
  20. const targetEl2 = document.querySelector(".weui-msg__desc")
  21. const targetEl = document.querySelector(".weui-msg .weui-msg__text-area .ui-ellpisis-content p");
  22. const zhihuLinkEl = document.querySelector(".link")
  23. const targetText = targetEl?.innerText
  24. const targetText2 = targetEl2?.innerText
  25. const zhihuTargetText = zhihuLinkEl?.innerText
  26. const urlReg = /^(http:|https:)/img;
  27. if(urlReg.test(targetText)) {
  28. return targetText
  29. }else if(urlReg.test(targetText2)) {
  30. return targetText2
  31. }else if(urlReg.test(zhihuTargetText)){
  32. return zhihuTargetText
  33. }
  34. return null;
  35. }
  36.  
  37. function redirect() {
  38. const url = getUrl()
  39. if(url) { window.location.href = url }
  40. }
  41. })();