translate-mainonly

bing translate and baidu translate mainonly

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         translate-mainonly
// @namespace    https://github.com//translate-mainonly
// @version      0.1
// @description  bing translate and baidu translate mainonly
// @author       liaoran2002
// @match        https://cn.bing.com/*
// @match        https://fanyi.baidu.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license      GPL-3.0
// @grant        none
// ==/UserScript==
var e = document.body;
const n = document.head.appendChild(document.createElement("style"));
n.textContent = ".mainonly { outline: 2px solid red; }";
const t = CSS.supports("selector(:has(*))");

function o(n) {
	n instanceof HTMLElement && (e.classList.remove("mainonly"), (e = n).classList.add("mainonly"))
}

function a() {
	if (t) {
		n.textContent = ":not(:has(.mainonly), .mainonly, .mainonly *) { display: none; }";
	} else {
		n.textContent = ":not(.mainonly *, .mainonly-ancestor) { display: none; }";
		var s = e;
		do {
			s.classList.add("mainonly-ancestor")
		} while (s = s.parentElement)
	}
}
try {
	console.log(`%c[translate-mainonly]已加载`, 'color: blue;font-size: large;font-weight: bold;');
	var sss = null;
	if (location.href.includes('cn.bing.com') && location.href.includes('q=%E7%BF%BB%E8%AF%91&')) {
		sss = document.getElementsByClassName('tta_tbl')[0];
	} else if (location.href.includes('fanyi.baidu.com')) {
		sss = document.getElementsByClassName('translate-main')[0];
	}
	if (sss) {
		o(sss);
		a();

	}
} catch (ex) {
	console.error(ex)
}