Skip to content

Instantly share code, notes, and snippets.

@nabbynz
Last active October 24, 2016 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabbynz/aa60350c5ae24a68da5e624839750fcf to your computer and use it in GitHub Desktop.
Save nabbynz/aa60350c5ae24a68da5e624839750fcf to your computer and use it in GitHub Desktop.
TagPro - Prevent JS Error Warning Box
// ==UserScript==
// @name Prevent JS Error Warning Box
// @description Prevents the red error warning appearing on your server homepage (hopefully)
// @version 0.0.5
// @include http://tagpro-*.koalabeast.com*
// @exclude http://tagpro-*.koalabeast.com:*
// @updateURL https://gist.github.com/nabbynz/aa60350c5ae24a68da5e624839750fcf/raw/prevent_jserror_warning.user.js
// @downloadURL https://gist.github.com/nabbynz/aa60350c5ae24a68da5e624839750fcf/raw/prevent_jserror_warning.user.js
// @grant none
// @author nabby
// ==/UserScript==
console.log('START: ' + GM_info.script.name + ' (v' + GM_info.script.version + ' by ' + GM_info.script.author + ')');
//----- Options -----
var normalWithFadeOut = true; //the warning message will fadeout after 3 seconds
var makeSmall = false; //the warning message is still visible but less obtrusive now (small red square with an "E" in the top-left corner)
var makeTiny = false; //the warning message is still visible but much less obtrusive now (small red circle in the top-left corner)
var alwaysHidden = false; //the warning message will never be visible (use with care as the warning message is there for a reason!)
//-------------------
var oldOnError = window.onerror;
window.onerror = function() {
if (oldOnError) oldOnError.apply(this, arguments);
var oldErrorMessage = $('.js-console-error').text().replace(/\.\s/g, '.\n');
if (makeTiny) {
$('.js-console-error').hide(0);
$('body').append('<div id="SJS_ShowOptions" style="position:absolute; top:10px; left:10px; width:5px; height:5px; background:#e00; border-radius:50%; cursor:default;" title="'+oldErrorMessage+'"></div>');
} else if (makeSmall) {
$('.js-console-error').hide(0);
$('body').append('<div style="position:absolute; top:10px; left:10px; width:20px; height:20px; background:#a00; color:#fff; text-align:center; font:15px Arial; font-style:italic; border:1px solid #e00; border-radius:5px; cursor:default;" title="'+oldErrorMessage+'">E</div>');
} else if (alwaysHidden) {
$('.js-console-error').hide(0);
} else {
$('.js-console-error').fadeOut(3000);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment