禁用浏览器的翻译功能。火狐和IE不支持。

该特性浏览器兼容情况:  https://developer.mozilla.org/zh-CN/docs/Web/HTML/Global_attributes/translate
This commit is contained in:
fangxiang 2022-06-17 15:39:41 +08:00
parent 3d3dfd505f
commit 4272ee1d6e
2 changed files with 29 additions and 21 deletions

View File

@ -38,15 +38,7 @@
"workbox-webpack-plugin": "^6.4.2"
},
"browserslist": [
"last 10 Chrome versions",
"last 10 Firefox versions",
"last 5 Edge versions",
"last 7 Safari versions",
"last 8 Android versions",
"last 8 ChromeAndroid versions",
"last 8 FirefoxAndroid versions",
"last 10 iOS versions",
"last 5 Opera versions"
"since 2015"
],
"engines": {
"node": ">= 12.22.1",

View File

@ -15,6 +15,8 @@
<meta name="x5-fullscreen" content="true" />
<meta name="screen-orientation" content="landscape" />
<meta name="x5-orientation" content="landscape" />
<meta name="google" content="notranslate" />
<script>
/*@cc_on window.location.href="http://support.dmeng.net/upgrade-your-browser.html?referrer="+encodeURIComponent(window.location.href); @*/
</script>
@ -54,22 +56,36 @@
</head>
<script src="./media_control_client_language.js"></script>
<script type="text/javascript">
window.user_search = {};
var search = window.location.search;
if (search.indexOf("?") != -1) {
search = search.substr(1);
var temp = search.split("&");
for (var i = 0; i < temp.length; i++) {
var info = temp[i].split("=");
if (info) {
if (info.length >= 2) {
window.user_search[info[0]] = decodeURI(info[1]);
} else if (info.length >= 1) {
window.user_search[info[0]] = null;
function parseSearch() {
window.user_search = {};
var search = window.location.search;
if (search.indexOf("?") != -1) {
search = search.substr(1);
var temp = search.split("&");
for (var i = 0; i < temp.length; i++) {
var info = temp[i].split("=");
if (info) {
if (info.length >= 2) {
window.user_search[info[0]] = decodeURI(info[1]);
} else if (info.length >= 1) {
window.user_search[info[0]] = null;
}
}
}
}
}
function setTranslateNo() {
for (let i = 0; i < document.children.length; ++i) {
const item = document.children[i];
if (item && item.nodeName.toUpperCase() == "HTML") {
item.setAttribute("translate", "no");
}
}
}
setTranslateNo();
parseSearch();
</script>
<body>