Greasy Fork

Greasy Fork is available in English.

链接直达

链接直达,去掉确定跳转链接页面

目前为 2020-12-23 提交的版本。查看 最新版本

// ==UserScript==
// @name        链接直达
// @description 链接直达,去掉确定跳转链接页面
// @namespace   https://github.com/WindrunnerMax/TKScript
// @version     1.0.0
// @author      Czy
// @include     *://www.google.com/*
// @include     *://www.zhihu.com/*
// @license     MIT License
// @require     https://cdn.bootcss.com/jquery/2.1.2/jquery.min.js
// @grant       unsafeWindow
// @grant       GM_xmlhttpRequest
// ==/UserScript==

(function () {
  'use strict';

  function styleInject(css, ref) {
    if (ref === void 0) ref = {};
    var insertAt = ref.insertAt;

    if (!css || typeof document === 'undefined') {
      return;
    }

    var head = document.head || document.getElementsByTagName('head')[0];
    var style = document.createElement('style');
    style.type = 'text/css';

    if (insertAt === 'top') {
      if (head.firstChild) {
        head.insertBefore(style, head.firstChild);
      } else {
        head.appendChild(style);
      }
    } else {
      head.appendChild(style);
    }

    if (style.styleSheet) {
      style.styleSheet.cssText = css;
    } else {
      style.appendChild(document.createTextNode(css));
    }
  }

  var css_248z = "";
  styleInject(css_248z);

  function init($) {
    $("#res a").attr("target", "_blank");
  }

  var google = {
    init: init
  };

  function init$1($) {
      console.log($("a"));
    $("a").each((i, v) => {
        const regexp = /https:\/\/link.zhihu.com\/\?target=(.*)/;
        if(v.href.match(regexp)) {
            v.href = v.href.replace(regexp, ($0, $1) => decodeURIComponent($1));
        }
    });
  }

  var zhihu = {
    init: init$1
  };

  (function () {
    var $ = window.$;

    var mather = function mather(regex, site) {
      if (regex.test(window.location.href)) {
        for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
          args[_key - 2] = arguments[_key];
        }

        site.init.apply(site, args);
      }
    };

    mather(/google/, google, $);
    mather(/zhihu/, zhihu, $);
  })();

}());