auto-continue-visit

A Tampermonkey script that help you to automatically continue to visit.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         auto-continue-visit
// @namespace    https://github.com/Xhofe/auto-continue-visit
// @version      0.0.2
// @author       Andy Hsu
// @description  A Tampermonkey script that help you to automatically continue to visit.
// @license      MIT
// @icon         https://cdn.jsdelivr.net/gh/Xhofe/auto-continue-visit/assets/logo.svg
// @match        https://link.zhihu.com*
// @match        https://leetcode.cn/link*
// @match        https://link.csdn.net*
// @match        https://link.juejin.cn*
// @match        https://gitee.com/link*
// @match        https://docs.qq.com/scenario/link.html*
// @match        https://hd.nowcoder.com/link.html*
// @match        https://www.oschina.net/action/GoToLink*
// @match        https://cloud.tencent.com/developer/tools/blog-entry*
// @match        https://c.pc.qq.com/middlem.html*
// @match        https://www.kdocs.cn/office/link*
// @match        https://link.zhihu.com/*
// @match        https://leetcode.cn/link/*
// @match        https://link.csdn.net/*
// @match        https://link.juejin.cn/*
// @match        https://gitee.com/link/*
// @match        https://docs.qq.com/scenario/link.html/*
// @match        https://hd.nowcoder.com/link.html/*
// @match        https://www.oschina.net/action/GoToLink/*
// @match        https://cloud.tencent.com/developer/tools/blog-entry/*
// @match        https://c.pc.qq.com/middlem.html/*
// @match        https://www.kdocs.cn/office/link/*
// ==/UserScript==

(function () {
  'use strict';

  const config = [
    {
      link: "https://link.zhihu.com",
      key: "target"
    },
    {
      link: "https://leetcode.cn/link",
      key: "target"
    },
    {
      link: "https://link.csdn.net",
      key: "target"
    },
    {
      link: "https://link.juejin.cn",
      key: "target"
    },
    {
      link: "https://gitee.com/link",
      key: "target"
    },
    {
      link: "https://docs.qq.com/scenario/link.html",
      key: "url"
    },
    {
      link: "https://hd.nowcoder.com/link.html",
      key: "target"
    },
    {
      link: "https://www.oschina.net/action/GoToLink",
      key: "url"
    },
    {
      link: "https://cloud.tencent.com/developer/tools/blog-entry",
      key: "target"
    },
    {
      link: "https://c.pc.qq.com/middlem.html",
      key: "pfurl"
    },
    {
      link: "https://www.kdocs.cn/office/link",
      key: "target"
    }
  ];
  async function sleep(ms) {
    return new Promise((resolve) => {
      setTimeout(resolve, ms);
    });
  }
  function takeFromQuery(cfg) {
    const { key, handler } = cfg;
    const url = new URL(location.href);
    let target = url.searchParams.get(key);
    if (!target) {
      return;
    }
    if (handler) {
      target = handler(target);
    }
    console.log(`[auto-continue-visit] ${target}`);
    window.open(target, "_self");
  }
  async function clickElement(cfg) {
    const { selector, delay = 0, times = 1, interval = 0 } = cfg;
    if (delay) {
      await sleep(delay);
    }
    for (let i = 0; i < times; i++) {
      const element = document.querySelector(selector);
      if (element) {
        element.click();
        break;
      }
      await sleep(interval);
    }
  }
  async function continueVisit(cfg) {
    if ("key" in cfg) {
      takeFromQuery(cfg);
    } else {
      clickElement(cfg);
    }
  }
  function main() {
    const origin = window.location.origin;
    const cfg = config.find((cfg2) => cfg2.link.startsWith(origin));
    console.log(`[auto-continue-visit] ${origin} ${cfg}`);
    if (!cfg) {
      return;
    }
    continueVisit(cfg);
  }
  main();

})();