// ==UserScript== // @name SpringManualJapanese // @namespace cypger256.SpringManualJapanese // @version 1.1 // @description docs.spring.io の日本翻訳版ページと公式を行ったり来たり出来ます // @author cypger256 // @match https://docs.spring.io/spring-boot/docs/* // @match https://spring.pleiades.io/* // @run-at document-end // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; var official = location.hostname == 'docs.spring.io'; function replaceLink() { return 'https://' + (official ? 'spring.pleiades.io' : 'docs.spring.io') + location.href.replace(/^https:..[^\/]+/, ''); } function toggleJapanese(e) { var a = document.getElementById('help_link'); a.href = replaceLink(); e.stopPropagation(); } var wapper = document.createElement('div'); wapper.style.position = 'fixed'; wapper.style.right = 0; wapper.style.top = 0; wapper.style.zIndex = 1; var link = document.createElement('a'); link.setAttribute('id', 'help_link'); link.setAttribute('href', replaceLink()); link.appendChild(document.createTextNode(official ? '日本語ページへ' : '英語ページへ')); link.addEventListener('click', toggleJapanese, false); link.addEventListener('mousedown', toggleJapanese, false); wapper.appendChild(link); var body = document.getElementsByTagName('body')[0]; body.insertBefore(wapper, body.firstChild); })();