您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automate the process of clicking the PDF download button and close the tab after 5 seconds if the button is found and clicked
// ==UserScript== // @name Horizon官网检查是否包含PDF // @namespace http://tampermonkey.net/ // @version 0.1 // @description Automate the process of clicking the PDF download button and close the tab after 5 seconds if the button is found and clicked // @author Kimi // @match https://techzone.omnissa.com/resource/* // @match https://techzone.omnissa.com/blog/* // @grant none // ==/UserScript== (function() { 'use strict'; // 记录初始访问的URL console.log('访问的URL:', window.location.href); // 等待页面完全加载后再执行脚本 window.onload = function() { // 页面加载完成后等待3秒 setTimeout(function() { // 查找包含特定类名的按钮 const pdfButton = document.querySelector('.print-pdf'); // 如果按钮存在,模拟点击事件 if (pdfButton) { pdfButton.click(); console.log('PDF download button clicked'); // 点击后等待5秒再关闭标签页 setTimeout(function() { console.log("关闭当前标签页"); window.close(); // 关闭当前标签页 }, 5000); } // 如果按钮不存在,等待3秒后刷新页面 else { console.log('PDF download button not found on this page. Refreshing in 3 seconds...'); setTimeout(function() { window.location.reload(); }, 3000); } }, 3000); // 等待3000毫秒,确保页面上的脚本已经加载了按钮 }; })();