CSDN刷浏览量

先点击获取,开着CSDN就会自动刷,知道请求有效时间间隔的朋友请评论giao诉我

目前為 2020-06-27 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         CSDN刷浏览量
// @namespace    https://xyw.baklib.com/
// @version      0.0.4
// @description  先点击获取,开着CSDN就会自动刷,知道请求有效时间间隔的朋友请评论giao诉我
// @author       Silencer
// @match        *://blog.csdn.net/*
// @match        *://*.csdn.net/*
// @icon         https://blog.csdn.net/favicon.ico
// ==/UserScript==

(function () {
  const config = {
    // 每个请求的间隔时间,过快会失败,单位:秒(不建议设置0.2以下,实测不行)
    time: 0.2,
    // 总请求的时间间隔,过快不计入,单位:秒(不知道怎么算的,就60秒一次吧)
    interval: 60,
    // 切割用的字符串,不要用 ':', '/', '.'等url会用到的字符
    str: '|'
  }

  function getUrl() {
    !localStorage.urlList && (localStorage.urlList = '')
    document.querySelectorAll('.csdn-tracking-statistics p a')
      .forEach(i => {
        i.href && (localStorage.urlList += i.href + config.str)
      })
    localStorage.urlList =
      [...new Set(localStorage.urlList
        .split(config.str)
      )]
        .filter(i => i)
        .join(config.str)
        .trim()
  }
  function request() {
    localStorage.urlList.split(config.str)
      .forEach((item, index) => {
        setTimeout(() => {
          fetch(item)
        }, index * config.time * 1000)
      })
  }

  (function main() {
    $(".opt-box").prepend(`<a class="btn btn-sm" id="getUrl" href="javascript:;">获取该页链接</a >`)
    // $(".opt-box").prepend(`<a class="btn btn-sm" id="clearUrl" href="javascript:;">清除链接</a >`)
    $('#getUrl').click(getUrl)
    // $('#clearUrl').click(() => { localStorage.urlList = '' })

    !localStorage.urlList && getUrl()
    request()
    setInterval(request, config.interval * 1000)
  })()
})()