【发布时间】:2018-05-10 08:19:14
【问题描述】:
基本上,我访问了一个特定的网站,我在计时器上设置了用户脚本自动刷新。此特定页面在刷新时会不时更改内容。我希望在页面刷新和任何页面更改发生时播放声音。
这是我目前收集的代码,但我仍然需要一些东西才能让它正常运行:
// ==UserScript==
// @name Auto-Refresh
// @include https://www.prolific.ac/studies
// ==/UserScript==
//--- https://stackoverflow.com/questions/25484978/i-want-a-simple-greasemonkey-script-to-reload-the-page-every-minute
setTimeout(function(){ location.reload(); }, 20*1000);
var player = document.createElement('audio');
player.src = 'https://notificationsounds.com/soundfiles/a86c450b76fb8c371afead6410d55534/file-sounds-1108-slow-spring-board.mp3';
player.preload = 'auto';
// Play a sound with condition and then player.play()
所以脚本的其余部分基本上是“如果发生页面更改(刷新后),则播放声音。”这就是我遇到麻烦的地方。
我一直使用这个线程作为指导:How to monitor a static HTML page for changes with Greasemonkey? Use a hash? 但我不太确定哪种方法最有效。任何和所有的建议将不胜感激。提前致谢。
【问题讨论】:
标签: javascript google-chrome userscripts page-refresh tampermonkey