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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Discord Embed Right Click Enabler
// @namespace    https://greasyfork.org
// @version      1.0
// @description  Re-enables right click on image and video embeds in Discord, since the new custom context menu update.
// @author       ScocksBox
// @icon         https://i.imgur.com/ZOKp8LH.png
// @include      https://discord.com/*
// @license      MIT
// @run-at       document-end
// @grant        none
// ==/UserScript==

/* jshint esversion: 6 */

var callback = function (mutationsList, observer) {
	let elements = document.querySelectorAll(".message-2CShn3 img:not(.avatar-2e8lTP):not(.replyAvatar-sHd2sU), .message-2CShn3 video");
	for (let i = 0; i < elements.length; i++) {
		let el = elements[i];
		if (!el.classList.contains("contextmenu-fixed")) {
			el.addEventListener('contextmenu', function(event) {
				event.stopImmediatePropagation();
			}, true);
			el.classList.add("contextmenu-fixed");
		}
	}
};

const observer = new MutationObserver(callback);
observer.observe(document.body, { childList: true, subtree: true });