houzz.com 2022

Allows riht-clicking and downloading of images.

  1. // ==UserScript==
  2. // @name houzz.com 2022
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Allows riht-clicking and downloading of images.
  6. // @author Mr. Wonderful
  7. // @match *://www.houzz.com/*
  8. // @icon https://www.houzz.com/favicon/favicon.ico
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/981320
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. // Ref https://stackoverflow.com/a/57065599
  15.  
  16. // Functions
  17. function enableContextMenu(aggressive = false) {
  18. void(document.ondragstart=null);
  19. void(document.onselectstart=null);
  20. void(document.onclick=null);
  21. void(document.onmousedown=null);
  22. void(document.onmouseup=null);
  23. void(document.body.oncontextmenu=null);
  24. enableRightClickLight(document);
  25. if (aggressive) {
  26. enableRightClick(document);
  27. removeContextMenuOnAll("body");
  28. removeContextMenuOnAll("img");
  29. removeContextMenuOnAll("td");
  30. } }
  31.  
  32. function removeContextMenuOnAll(tagName) {
  33. var elements = document.getElementsByTagName(tagName);
  34. for (var i = 0; i < elements.length; i++) {
  35. enableRightClick(elements[i]);
  36. }
  37. }
  38.  
  39. function enableRightClickLight(el) {
  40. el || (el = document);
  41. el.addEventListener("contextmenu", bringBackDefault, true);
  42. }
  43.  
  44. function enableRightClick(el) {
  45. el || (el = document);
  46. el.addEventListener("contextmenu", bringBackDefault, true);
  47. el.addEventListener("dragstart", bringBackDefault, true);
  48. el.addEventListener("selectstart", bringBackDefault, true);
  49. el.addEventListener("click", bringBackDefault, true);
  50. el.addEventListener("mousedown", bringBackDefault, true);
  51. el.addEventListener("mouseup", bringBackDefault, true);
  52. }
  53.  
  54. function restoreRightClick(el) {
  55. el || (el = document);
  56. el.removeEventListener("contextmenu", bringBackDefault, true);
  57. el.removeEventListener("dragstart", bringBackDefault, true);
  58. el.removeEventListener("selectstart", bringBackDefault, true);
  59. el.removeEventListener("click", bringBackDefault, true);
  60. el.removeEventListener("mousedown", bringBackDefault, true);
  61. el.removeEventListener("mouseup", bringBackDefault, true);
  62. }
  63.  
  64. function bringBackDefault(event) {
  65. event.returnValue = true;
  66. (typeof event.stopPropagation === 'function') &&
  67. event.stopPropagation();
  68. (typeof event.cancelBubble === 'function') &&
  69. event.cancelBubble();
  70. }
  71.  
  72. function addCSS(styles) {
  73. var styleSheet = document.createElement("style")
  74. styleSheet.innerText = styles
  75. document.head.appendChild(styleSheet)
  76. }
  77.  
  78. // Force-allow right-clicks
  79. enableContextMenu();
  80.  
  81. // Remove image overlay
  82. addCSS(`.hz-color-picker__markers { display: none !important; }`);