123网盘自动填写提取码、关闭广告

如名

// ==UserScript==
// @name         123网盘自动填写提取码、关闭广告
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  如名
// @author       CCCC-L
// @match        https://www.123pan.com/s/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=123pan.com
// @grant        none
// @run-at       document-start
// ==/UserScript==



(function() {
    'use strict';

    // 关闭广告
    let adInterval = setInterval(() => {
        let ad = document.querySelectorAll("[class^=banner-container]")
        if (ad.length) {
            clearInterval(adInterval)
            ad.forEach(ad => ad.remove())
            setTimeout(() => document.getElementsByClassName("appBottomBtn")[0].style.bottom = 0, 100)
        }
    }, 100);


    // 获取pwd参数
    let pwd = new URLSearchParams(window.location.search).get("pwd")
    // 没有pwd参数提前返回
    if (!pwd) {
        return
    }

    let shareKey = window.location.pathname.match(/\w+-\w+/)[0]
    localStorage.setItem("shareKey", shareKey)
    localStorage.setItem("SharePwd", pwd)
})();