Greasy Fork

Greasy Fork is available in English.

中转页面自动跳转

某些网站打开链接会进入安全中转页面,此脚本实现自动跳转功能

当前为 2021-09-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         中转页面自动跳转
// @namespace    dhjesus
// @version      0.0.6
// @keywords     微信,稀土掘金,CSDN,知乎
// @description  某些网站打开链接会进入安全中转页面,此脚本实现自动跳转功能
// @author       DHJesus
// @include     *://weixin110.qq.com/*
// @include     *://link.juejin.cn/*
// @include     *://link.csdn.net/*
// @include     *://link.zhihu.com/*
// @grant        none
// @compatible	 Chrome
// @compatible	 Firefox
// @compatible	 Edge
// @compatible	 Safari
// @compatible	 Opera
// @compatible	 UC
// ==/UserScript==

(function () {
  var host = window.location.host;
  function getQueryVariable(variable) {
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
  }

  if(host.indexOf('weixin110') != -1) {
    window.location.href = document.getElementsByClassName('weui-msg__desc')[0].textContent;
  }
  
  if(host.indexOf('juejin') != -1) {
    var target = decodeURIComponent(getQueryVariable('target'));
    window.location.href = target;
    // window.location.href = document.getElementsByTagName('p')[1].textContent;
  }
  
  if(host.indexOf('csdn') != -1) {
    var target = decodeURIComponent(getQueryVariable('target'));
    window.location.href = target;
  }
  
  if(host.indexOf('zhihu') != -1) {
    var target = decodeURIComponent(getQueryVariable('target'));
    window.location.href = target;
  }
})();