// ==UserScript== // @name 获取refresh_token // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://www.aliyundrive.com/drive/ // @icon https://www.google.com/s2/favicons?sz=64&domain=aliyundrive.com // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; let token = localStorage.getItem("token"); token = JSON.parse(token); let refresh_token = token["refresh_token"]; console.log(token["refresh_token"]); let bt = document.createElement("div"); bt.style=`padding: 2px 4px; color: var(--context_primary); border-radius: 5px; background-color: var(--divider_secondary); cursor: pointer; font-size: 12px;` bt.textContent="获取"; /* let dd = document.body.getElementsByClassName("top-wrapper--d-YJl")[0]; dd.appendChild(bt); */ var myVar = setInterval(function(){ myTimer() }, 1000); function myTimer() { if(document.querySelector('#root .top-wrapper--d-YJl')!=null){ let bt = document.createElement("div"); bt.style=`padding: 2px 4px; color: var(--context_primary); border-radius: 5px; background-color: var(--divider_secondary); cursor: pointer; font-size: 12px;` bt.textContent="获取"; bt.onclick = function () { var aux = document.createElement("input"); aux.setAttribute("value", refresh_token); document.body.appendChild(aux); aux.select(); document.execCommand("copy"); document.body.removeChild(aux); alert("复制成功"); window.location.href = "http://localhost:9798/"; }; document.querySelector('#root .top-wrapper--d-YJl').appendChild(bt); myStopFunction(); } } function myStopFunction() { clearInterval(myVar); } // Your code here... })();