Greasy Fork

Greasy Fork is available in English.

Javadoc translate

Java文档的翻译优化。需提前打开Chrome的自带翻译,并选择自动翻译英文网页。

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Javadoc translate
// @namespace    http://tampermonkey.net/
// @version      0.2.3
// @description  Java文档的翻译优化。需提前打开Chrome的自带翻译,并选择自动翻译英文网页。
// @author       再见
// @icon         https://www.google.com/s2/favicons?domain=ow2.io
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js
// @grant        none
// @match        http://*/*
// @match        https://*/*
// ==/UserScript==
//自行添加匹配的网址
//禁止被翻译的区域 .notranslate
//jdk9
const index = [
    $('[class*=col-first]'),
]
const overview = [
    $('.header>.title'),
    $('.contentContainer>div>ul>li>a'),
    $('.colFirst>a'),
    //jdk9
    $('.colLast>.block>a')
]
const model = [
    $('[class*=col-first]'),
    $('[class*=col-last] a'),
]
const packages = [
    $('caption'),
    $('.colFirst'),
    $('.code'),
    //jdk9
    $('.col-first')
]
const clazz = [
    $('.header'),
    $('.memberSummary>tbody>.colFirst'),
    $('.blockList>h4'),
    $('.blockList>pre'),
    $('.inherited-list'),
    $('.code'),
    //jdk9
    $('.inheritance'),
    $('.type-signature'),
    $('.detail>h3'),
    $('.detail a'),
    $('.member-signature')
]
const classUse = [
    $('.header>.title'),
    $('.blockList option'),
    $('.blockList>h3'),
    $('.colFirst'),
    $('.colLast>.typeNameLabel'),
    $('.colLast>code'),
    //jdk9
    $('.col-first'),
    $('.detail>h2'),
    $('.detail>.caption'),
    $('.col-second'),
    $('.summary-table a'),
]
~(function() {
    'use strict';
    var pn = location.pathname
    let local = overview
    switch(true) {
        case pn.endsWith('index.html'):
            console.log(location)
            if ($('[name=classFrame]').length != 0) location.href = location.origin + pn.replace('index.html','overview-summary.html')
            else local = index
            break
        case pn.endsWith('module-summary.html'):
            local = model
            break
        case pn.endsWith('package-summary.html'):
            local = packages
            break
        case pn.endsWith('overview-summary.html'):
            local = overview
            break
        case pn.includes('class-use'):
            local = classUse
            break
        default:
            local = clazz
    }
    local.forEach(function(e) {e.addClass('notranslate')})
})();