油猴脚本自动刷新找库存
date
Feb 6, 2022
slug
tampermonkey-auto-refresh-script
status
Published
summary
小技巧 通过自动刷新来查找页面上的相应变化
tags
tip
type
Post
URL
Problem & Summary
Soltion
// ==UserScript==
// @name auto-refresh-比如检测斯巴达
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 斯巴达库存检测。
// @author kzus
// @match https://billing.spartanhost.net/cart.php*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var x = document.querySelector("#order-boxes > div > h1")
if(x==null){
play()
document.body.style.backgroundColor = "yellow";
console.log("有库存!!!")
alert("有库存!!!!!!!");
}else{
console.log("没库存")
//time以毫秒为单位
let time=10000; // 每10s自动更新
setTimeout(() => {
location.reload()
},time);
}
})();
function play() {
var audio = new Audio('https://www.w3school.com.cn/i/horse.mp3');
audio.crossorigin="anonymous";
audio.loop=true;
audio.play();
}