Forked from anonymous/prevent-object-insertion-1.1.user.js
Last active
August 6, 2016 15:16
-
-
Save blueberrystream/b2b39c7400c08b18fe29d8086093ce4f to your computer and use it in GitHub Desktop.
This file contains 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 Prevent OBJECT Insertion | |
// @version 1.2 | |
// @description OBJECT要素の挿入を阻止します。「Amazonが重い」問題(Bug 1172205)を回避できるかもしれません。 | |
// @id f4cce630-3501-4d9f-a846-d69064429f02 | |
// @namespace f4cce630-3501-4d9f-a846-d69064429f02 | |
// @include http*://www.amazon.com/* | |
// @include http*://www.amazon.com.au/* | |
// @include http*://www.amazon.com.br/* | |
// @include http*://www.amazon.ca/* | |
// @include http*://www.amazon.cn/* | |
// @include http*://www.amazon.fr/* | |
// @include http*://www.amazon.de/* | |
// @include http*://www.amazon.in/* | |
// @include http*://www.amazon.it/* | |
// @include http*://www.amazon.co.jp/* | |
// @include http*://www.amazon.com.mx/* | |
// @include http*://www.amazon.nl/* | |
// @include http*://www.amazon.es/* | |
// @include http*://www.amazon.co.uk/* | |
// @grant none | |
// @run-at document-start | |
// @noframes | |
// @copyright No copyright. this program is in the public domain. | |
// ==/UserScript== | |
/* | |
Amazonが重くて且つ「Greasemonkeyを無効にすると軽くなる」という人は | |
このスクリプトを試す前に、 | |
Greasemonkey本体の設定の「実行しないページ」のリストに | |
*images-amazon.com/* | |
を追加してみてください。 | |
設定の場所は ツールバーボタンのメニューの「Greasemonkey オプション(O)...」 | |
または アドオンマネージャ → 拡張機能 → Greasemonkeyの「設定」ボタン | |
または Alt+T → G → O | |
*/ | |
/// ChangeLog | |
// 1.1 <2015-07-07> | |
// - Scriptish 及び UserScriptLoader.uc.js に対応。 | |
// - 「商品の説明」ページ(IFRAME要素内)では実行されないようにした。 | |
// - insertBefore 関数の書き換えを止めた。 | |
// - ブロックしたOBJECT要素をコンソールログに表示。 | |
// 1.0 <2015-06-12> | |
// - 公開。 | |
// https://gist.github.com/anonymous/8c1fa6e27eaef2addc80/ | |
// http://anago.2ch.net/test/read.cgi/software/1433432508/773-774n | |
if (window.frameElement === null) { | |
var SCRIPT_ID = "f4cce630-3501-4d9f-a846-d69064429f02".toUpperCase(); | |
var script = document.createElement("script"); | |
script.type = "application/javascript"; | |
script.id = SCRIPT_ID; | |
script.textContent = ' \n\ | |
(function(){ \n\ | |
var TARGET_FUNCTION_NAMES = ["appendChild"]; \n\ | |
var ORIG_SUFFIX = "-ORIGINAL-" + document.currentScript.id; \n\ | |
TARGET_FUNCTION_NAMES.forEach(function(name){ \n\ | |
window.HTMLElement.prototype[name + ORIG_SUFFIX] \n\ | |
= window.HTMLElement.prototype[name]; \n\ | |
window.HTMLElement.prototype[name] = function() { \n\ | |
var node = arguments[0]; \n\ | |
if (node.nodeName !== "OBJECT") \n\ | |
node = this[name + ORIG_SUFFIX].apply(this, arguments); \n\ | |
else { \n\ | |
console.log("Blocked: %o", node); \n\ | |
node = null; \n\ | |
} \n\ | |
return node; \n\ | |
} \n\ | |
}); \n\ | |
})();\n'.replace(/ +$/mg, ""); | |
document.addEventListener("DOMNodeInserted", function(){ | |
var head = document.getElementsByTagName("head").item(0); | |
if (head && !document.getElementById(SCRIPT_ID)) { | |
head.appendChild(script); | |
this.removeEventListener("DOMNodeInserted", arguments.callee, false); | |
} | |
}, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment