User:JJPMaster/widgets.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".script").text()) && $(".script").length())) {
		console.error("If this page contains a widget, it is not in your personal preferences, and the widget has been disabled as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this widget is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {	
		$(".script").html('<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.3.1/p5.min.js"></script><script type="module">' + $(".module").text() + '</' + 'script>');
	}
});
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".module").text()) && $(".module").length())) {
		console.error("If this page contains a widget, it is not in your personal preferences, and the widget has been disabled as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this widget is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {
		$(".module").html('<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.3.1/p5.min.js"></script><script type="module">' + $(".module").text() + '</' + 'script>');
	}
});
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".tensorflow").text()) && $(".tensorflow").length())) {
		console.error("If this page contains a widget, it is not in your personal preferences, and the widget has been disabled as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this widget is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {
		$(".tensorflow").html('<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.3.1/p5.min.js"></script><script>' + $(".tensorflow").text() + '</' + 'script>');
	}
});
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".src").text()))) {
		console.error("This page embeds content or code from an external website that is not on your personal whitelist, and as such, the content has not been embedded as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this website is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {
		$(".src").html('<script src="' + $(".src").text() + '"></script>');
	}
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".html").text()) && $(".html").length())) {
		console.error("If this page contains a widget, it is not in your personal preferences, and the widget has been disabled as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this widget is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {
		$(".html").html($(".html").text());
	}
});
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".nolib").text()) && $(".nolib").length())) {
		console.error("If this page contains a widget, it is not in your personal preferences, and the widget has been disabled as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this widget is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {
		$(".nolib").html('<script>' + $(".nolib").text() + '</' + 'script>');
	}
});
	
$.getJSON('/w/index.php?title=User:' + mw.config.get('wgUserName') + '/widgetconfig.json&action=raw&ctype=application/json', function( data ) {
	if(!(data.widgets.includes($(".embed").text()))) {
		console.log($(".embed").text());
		console.error("This page embeds content or code from an external website that is not on your personal whitelist, and as such, the content has not been embedded as a security precaution. See https://en.wikipedia.org/wiki/Cross-site_scripting for further information. If you believe this website is secure, add it to https://en.uncyclopedia.co/wiki/Special:MyPage/widgetconfig.json by reading the instructions at https://en.uncyclopedia.co/wiki/User:JJPMaster/widgets and then reload this page.");
		throw new Error('Widgets security check failed.');
	}
	else {
		$(".embed").html('<embed src=' + $(".embed").text() + '>');
	}
});
});