JustJumpAhead

自动完成掘金、简书、知乎、百度贴吧、PC端QQ的跳转询问界面的点击工作,实现自动跳转

질문, 리뷰하거나, 이 스크립트를 신고하세요.
/*
 * @Descripttion: 
 * @version: 
 * @Author: LiarCoder
 * @Date: 2021-09-29 19:12:14
 * @LastEditors: LiarCoder
 * @LastEditTime: 2021-10-04 17:12:11
 */
// ==UserScript==
// @name         JustJumpAhead
// @namespace    http://tampermonkey.net/
// @version      0.3.2
// @description  自动完成掘金、简书、知乎、百度贴吧、PC端QQ的跳转询问界面的点击工作,实现自动跳转
// @author       LiarCoder
// @match        *://link.juejin.cn/*
// @match        *://link.zhihu.com/*
// @match        *://www.jianshu.com/go-wild*
// @match        *://jump.bdimg.com/safecheck*
// @match        *://link.csdn.net/*
// @match        *://c.pc.qq.com/middlem.html*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFHGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3R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dYDgE/nF1dW4pLmZnuXa+xnS3m55aKj81w5U3f712G43W5kZGQwqZDLFQhHBNLX58T8fBAStuUqlSo+4/uLc97sL923r2qwo8N6cC7wD+6MuKHX5+DQoQrQ3UckEl31Bc/zZHFRwOidccgSyQQziFi4qSA1+MsNzmRaj8RKiiYLdHW1UCqVOHqsGoWFBWg889ljBkyBJJQUfv/fFCCRwL3xiYr2C5ezU6nUk3h8RU7ZNHLqyDUHEio7DevWGcRcrf7NsbEJZryk0fgMNKys4++dapLJdIT5ITszn/ogf/X8bzCfsODVJlJtrmuPxeKSaDSKp09D+BchHM1xGrj+SAAAAABJRU5ErkJggg==
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  setTimeout(() => {
    // jumpBtn 是各个跳转页面中的类似于【继续访问】的按钮,用户可以点击按钮以继续访问被拦截的链接
    let jumpBtn = null;
    // targetAddress 是针对像在PC端QQ中的拦截页面中需要用户手动复制的目标链接
    let targetAddress = '';
    // currentAddress 是当前拦截页面的完整网址
    let currentAddress = location.toString();
    // buttonMap 存储了相应拦截页面与其中的【继续访问】按钮的CSS选择器映射关系
    let buttonMap = new Map();
    // addressMap 存储了相应拦截界面与其中的需要用户手动复制的网址的CSS选择器的映射关系
    let addressMap = new Map();

    // 匹配掘金的跳转拦截页面网址
    buttonMap.set('://link.juejin.cn/', '#app > div > div > button');
    // 匹配简书的跳转拦截页面网址
    buttonMap.set('://www.jianshu.com/go-wild', '._3OuyzjzFBDdQwRGk08HXHz_0');
    // 匹配知乎的跳转拦截页面网址
    buttonMap.set('://link.zhihu.com/', 'a.button');
    // 匹配百度贴吧的跳转拦截页面网址
    buttonMap.set('://jump.bdimg.com/safecheck', 'div.warning_info.fl > a:nth-child(2)');
    // 匹配CSDN的跳转拦截页面网址
    buttonMap.set('://link.csdn.net/', 'a.loading-btn');

    // 匹配PC端QQ的跳转拦截页面网址
    addressMap.set('://c.pc.qq.com/middlem.html', '#url');

    // 开始逐个遍历 buttonMap 中的 key 值,若有匹配上的,则获取相应按钮元素并自动点击完成跳转
    for (let address of buttonMap.keys()) {
      if (currentAddress.indexOf(address) >= 0) {
        jumpBtn = document.querySelector(buttonMap.get(address));
        jumpBtn.click();
        return;
      }
    }

    // 开始逐个遍历 addressMap 中的 key 值,若有匹配上的,则自动将浏览器的location指向目标网站完成跳转
    for (let address of addressMap.keys()) {
      if (currentAddress.indexOf(address) >= 0) {
        targetAddress = document.querySelector(addressMap.get(address)).innerText;
        location = targetAddress;
        return;
      }
    }
  }, 200);
})();