Google Form Heavy Traffic Checker

try to take over the world!

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Google Form Heavy Traffic Checker
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  try to take over the world!
// @author       You
// @match        https://docs.google.com/forms/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
	'use strict';

	Audio.prototype.play = (function (play) {
		return function () {
			var audio = this,
				args = arguments,
				promise = play.apply(audio, args);
			if (promise !== undefined) {
				promise.catch(_ => {
					// Autoplay was prevented. This is optional, but add a button to start playing.
					var el = document.createElement("button");
					el.innerHTML = "Play";
					el.addEventListener("click", function () {
						play.apply(audio, args);
					});
					this.parentNode.insertBefore(el, this.nextSibling)
				});
			}
		};
	})(Audio.prototype.play);

	function reload() {
		console.log("reloading page")
		location.reload()
	}

    function playaudio() {
        console.log("playing audio...")
    document.querySelector("body > audio").play()
    setTimeout(playaudio, 1000);
    }
	var text = document.querySelector("#innerContainer")
	if (text != null) {
		if (text.textContent.includes("heavy traffic")) {
			console.log("meh")
			var customText = document.createElement("h1")
			customText.textContent = "Hmm. Heavy traffic... Reloading in 5 seconds."
			text.appendChild(customText)
			setTimeout(reload, 5000);
		}
	} else {
		console.log("YEAHHH")
        // playaudio()
        // enable if you want ^^^
	}

	// Your code here...
})();