Discord Embed Right Click Enabler

Re-enables right click on image and video embeds in Discord, since the new custom context menu update.

当前为 2022-02-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Discord Embed Right Click Enabler
  3. // @namespace https://greasyfork.org
  4. // @version 1.0.1
  5. // @description Re-enables right click on image and video embeds in Discord, since the new custom context menu update.
  6. // @author ScocksBox
  7. // @icon https://i.imgur.com/ZOKp8LH.png
  8. // @include https://discord.com/*
  9. // @license MIT
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. /* jshint esversion: 6 */
  15.  
  16. var callback = function (mutationsList, observer) {
  17. let elements = document.querySelectorAll(".message-2CShn3 img:not(.avatar-2e8lTP):not(.replyAvatar-sHd2sU), .message-2CShn3 video");
  18. for (let i = 0; i < elements.length; i++) {
  19. let el = elements[i];
  20. if (!el.classList.contains("contextmenu-fixed")) {
  21. el.addEventListener('contextmenu', function(event) {
  22. event.stopImmediatePropagation();
  23. }, true);
  24. el.classList.add("contextmenu-fixed");
  25. }
  26. }
  27. };
  28.  
  29. const observer = new MutationObserver(callback);
  30. observer.observe(document.body, { childList: true, subtree: true });