Adds an entry to the context menu for translating selected text with m.dict.cc/deen in a pop-up window. If you're logged into your dict.cc account you will also be able to add translations to your vocabulary lists. Doesn't work with the Chrome pdf viewer.
// ==UserScript==
// @name Dict.cc | DE-EN
// @description Adds an entry to the context menu for translating selected text with m.dict.cc/deen in a pop-up window. If you're logged into your dict.cc account you will also be able to add translations to your vocabulary lists. Doesn't work with the Chrome pdf viewer.
// @version 1.0.0
// @namespace https://github.com/Fenn3c401
// @author Fenn3c401
// @license GPL-3.0-or-later
// @icon https://www.google.com/s2/favicons?sz=64&domain=dict.cc
// @match *://*/*
// @run-at context-menu
// @grant GM_openInTab
// ==/UserScript==
'use strict';
const selection = window.getSelection(),
selectionText = selection ? selection.toString().trim() : '',
url = `https://m.dict.cc/deen/?s=${encodeURIComponent(selectionText)}`,
newWindow = open(url, 'dict.cc', 'popup=true,width=350,height=600,top=10000,left=10000'); // high top left vals for correct bottom right positioning on active window in multi-monitor setup
if (!newWindow) GM_openInTab(url, { active: true, insert: true, setParent: true });