我有一个tampermonkey脚本,有时无法启动。
// ==UserScript==
// @name Hitbox Emotes
// @namespace Hitbox Emotes
// @description The original Hitbox Emotes script with ober 13,000 emotes! - Request your custom emotes and mod badges here!
// @include *.hitbox.tv/*
// @include *.vgstreams.com/*
// @include *.multistream.xuzia.com/*
// @icon http://i.imgur.com/fa1Kkku.png
// @version 1.3.6
// ==/UserScript==
function init()
{
console.log("this is %o, event is %o, host is %s");
var MainEmotes = document.createElement('script');
MainEmotes.type = 'text/javascript';
MainEmotes.src = "https://dl.dropboxusercontent.com/u/23313911/javascript/MainEmotes.js";
var CustomStyle = document.createElement('link');
CustomStyle.setAttribute('rel', 'stylesheet');
CustomStyle.setAttribute('type', 'text/css');
CustomStyle.setAttribute('href', 'https://dl.dropboxusercontent.com/u/23313911/css/CustomStyle.css')
var BackupEmotes = document.createElement('script');
BackupEmotes.type = 'text/javascript';
BackupEmotes.src = "https://cdn.rawgit.com/GamingTom/11142192/raw/fdd206a1a9e892a0f0c55f1de253981d980fa0e8/MainEmotes.js";
var CustomEmotes = document.createElement('script');
CustomEmotes.type = 'text/javascript';
CustomEmotes.src = "https://dl.dropboxusercontent.com/u/23313911/javascript/CustomEmotes.js";
var CustomBadges = document.createElement('script');
CustomBadges.type = 'text/javascript';
CustomBadges.src = "https://dl.dropboxusercontent.com/u/23313911/javascript/CustomBadges.js";
var head = document.getElementsByTagName('head')[0];
if (head) {
head.appendChild(MainEmotes);
console.info("Hitbox Emotes: Main emotes loaded from " + MainEmotes.src)
head.appendChild(BackupEmotes);
console.info("Hitbox Emotes: Backup emotes loaded from " + BackupEmotes.src)
head.appendChild(CustomEmotes);
console.info("Hitbox Emotes: Custom emotes loaded from " + CustomEmotes.src)
head.appendChild(CustomBadges);
console.info("Hitbox Emotes: Custom badges loaded from " + CustomBadges.src)
head.appendChild(CustomStyle);
}
}
window.onload = init;
我认为这可能与
有关window.onload = init;
但是如果我只是调用该函数,我会得到错误"未捕获的ReferenceError:没有定义表达情感"因为在调用页面时,页面有时不会完全加载。
如果有人知道如何让页面在页面加载后始终启动,那就太棒了!如果您需要更多信息,请询问。非常感谢任何帮助!
- 汤姆