BSI Translate

1/2/2024, 12:09:20 PM

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        BSI Translate
// @namespace   Violentmonkey Scripts
// @match       file:///home/lumi/Downloads/BSI%20CRM%20-%20dupl010.html*
// @match       http://127.0.0.1:8081/BSI%20CRM%20-%20dupl010.html*
// @match       https://prd.bsicrm.arvato-scs.com/bsicrm/*
// @grant       none
// @version     1.0
// @author      Jakub Duplaga
// @description 1/2/2024, 12:09:20 PM
// @run-at     document-idle
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @require https://translate.google.com/translate_a/element.js
// @license MIT
// ==/UserScript==

// Translate only the iframe
document.getElementsByTagName( 'html' )[0].setAttribute( 'class', 'notranslate' );
$("iframe[class='iframe field alternative']").addClass("translate");

// Create a translate button
$("div[class='menu-item unfocusable ellipsis overflow-tab-item has-text hidden']").after('<button id="but" type="button", class="tab-item marked active title", style="padding:4px;padding-bottom:4px;border:none;background:none;">Translate</button>');

// Create the languege change div
$('#but').after('<div id="google_translate_element" class="tab-item"></div>');

// Handle the translate button
$('#but').click(function(){
  new google.translate.TranslateElement({pageLanguage: 'auto', layout: google.translate.TranslateElement.InlineLayout.SIMPLE,  includedLanguages: 'en,pl,de',}, 'google_translate_element');
});