Created
August 17, 2011 23:18
-
-
Save XP1/1152892 to your computer and use it in GitHub Desktop.
Disable External Scripts: Disables external scripts by preventing them from running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Disable External Scripts | |
// @version 1.00 | |
// @description Disables external scripts by preventing them from running. | |
// @author XP1 (https://github.com/XP1/) | |
// @namespace https://gist.github.com/1152892/ | |
// @include file://localhost/* | |
// ==/UserScript== | |
/*jslint browser: true, vars: true, white: true, maxerr: 50, indent: 4 */ | |
(function (opera) | |
{ | |
"use strict"; | |
var languages = | |
{ | |
en: | |
{ | |
disableExternalScriptsConfirmation: "Do you want to disable external scripts?" | |
} | |
}; | |
var options = | |
{ | |
language: languages.en, | |
shouldConfirmDisableExternalScripts: true | |
}; | |
var isConfirmed = false; | |
var shouldDisableExternalScripts = false; | |
var disableExternalScripts = function (userJsEvent) | |
{ | |
if (options.shouldConfirmDisableExternalScripts && !isConfirmed) | |
{ | |
shouldDisableExternalScripts = window.confirm(options.language.disableExternalScriptsConfirmation); | |
isConfirmed = true; | |
if (!shouldDisableExternalScripts) | |
{ | |
opera.removeEventListener("BeforeExternalScript", disableExternalScripts, false); | |
return; | |
} | |
} | |
userJsEvent.preventDefault(); | |
userJsEvent.stopPropagation(); | |
}; | |
opera.addEventListener("BeforeExternalScript", disableExternalScripts, false); | |
}(window.opera)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I posted this user JS in this thread:
Bug: Opera freezes or crashes while opening saved html files:
http://my.opera.com/community/forums/topic.dml?id=1075222