Skip to content

Instantly share code, notes, and snippets.

@XP1
Created August 17, 2011 23:18
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 XP1/1152892 to your computer and use it in GitHub Desktop.
Save XP1/1152892 to your computer and use it in GitHub Desktop.
Disable External Scripts: Disables external scripts by preventing them from running.
// ==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));
@XP1
Copy link
Author

XP1 commented Aug 17, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment