Greasy Fork is available in English.

Prevent OBJECT Insertion

To avoid a problem of Amazon, maybe. See Bug 1172205.

  1. // ==UserScript==
  2. // @name Prevent OBJECT Insertion
  3. // @description To avoid a problem of Amazon, maybe. See Bug 1172205.
  4. // @description:ja-JP 「Amazonが重い」問題を回避できるかもしれません。
  5. // @namespace f4cce630-3501-4d9f-a846-d69064429f02
  6. // @include /^https?://(?:www\.amazon\.(?:c(?:o(?:\.(?:jp|uk)|m(?:\.(?:au|br|mx))?)|[an])|de|es|fr|i[nt]|nl))/.*/
  7. // @version 1.0
  8. // @grant none
  9. // @run-at document-start
  10. // @copyright No copyright. this program is in the public domain.
  11. // ==/UserScript==
  12.  
  13. // 1172205 – Amazon preloads resources with <object> tags causing the throbber to blink heavily shortly after page load
  14. // https://bugzilla.mozilla.org/show_bug.cgi?id=1172205
  15.  
  16. var TARGET_NAME = "OBJECT";
  17. var ORIG_SUFFIX = "-original-f4cce630-3501-4d9f-a846-d69064429f02";
  18.  
  19. ["appendChild", "insertBefore"].forEach(function(name){
  20. window.HTMLElement.prototype[name + ORIG_SUFFIX] = window.HTMLElement.prototype[name];
  21. window.HTMLElement.prototype[name] = function() {
  22. var node = arguments[0];
  23. if (node.nodeName !== TARGET_NAME)
  24. node = this[name + ORIG_SUFFIX].apply(this, arguments);
  25. else {
  26. // console.log("Blocked: " + node.outerHTML);
  27. node = null;
  28. }
  29. return node;
  30. }
  31. });