kitasenjudesign
my name is kitasenju design.
userscript
script.js
/* 英次郎&ケンブリッジへのリンクを挿入 */
scrapbox.PageMenu.addMenu({
title: 'insert eijiro/cambridge link',
image: 'https://scrapbox.io/files/6616066cf226080024a3f40d.png',
onClick: () => {
let hoge = encodeURIComponent(scrapbox.Page.title) + "";
insertText("\n[https://eow.alc.co.jp/search?q="+hoge+" ⬆️️:"+hoge+"]\n");
insertText("[https://dictionary.cambridge.org/dictionary/english/"+hoge+" 🌎️️:"+hoge+"]\n");
}
});
/* speechAPIの発音 */
scrapbox.PageMenu.addMenu({
title: 'pronounce on browser',
image: 'https://scrapbox.io/files/661c7758df12b200259a22eb.png',
onClick: () => {
let hoge = scrapbox.Page.title + "";
let utterance = new SpeechSynthesisUtterance(hoge);
utterance.lang = "en-US"
window.speechSynthesis.speak(utterance);
}
});
/* キーワードを挿入 */
scrapbox.PageMenu.addMenu({
title: 'add keyword',
image: 'https://i.gyazo.com/7057219f5b20ca8afd122945b72453d3.png',
onClick: () => {
let title = encodeURIComponent(scrapbox.Page.title) + "";
insertText("【辞】[https://eow.alc.co.jp/search?q="+title+" ⬆️️:"+title+"]\n【読】\n【類】\n【反】\n");
}
});
/* ukonowへのリンクを挿入 */
scrapbox.PageMenu.addMenu({
title: '類似',
image: 'https://scrapbox.io/files/665c0231fc368d001d502dc5.png',
onClick: () => {
let title = encodeURIComponent(scrapbox.Page.title) + "";
insertText("[https://synonyms.reverso.net/%E9%A1%9E%E7%BE%A9%E8%AA%9E/en/"+title+" 🐵:"+title+"]\n");
insertText("[https://forvo.com/search/"+title+" 📣:"+title+"]\n");
}
});
/* ----------------------------- */
/* ページ変更の監視 とspeechAPI*/
var title = ""
window.setInterval(()=>{
if(title!=scrapbox.Page.title){
let hoge = scrapbox.Page.title;
if(hoge!=null){
let utterance = new SpeechSynthesisUtterance(""+hoge);
utterance.lang = "en-US"
utterance.volume = 0.6;
window.speechSynthesis.speak(utterance);
}
}
title=scrapbox.Page.title;
},600);
export function insertText(text) {
const cursor = document.getElementById('text-input');
cursor.focus();
cursor.value = text;
const uiEvent = document.createEvent('UIEvent');
uiEvent.initEvent('input', true, false);
cursor.dispatchEvent(uiEvent);
}
shortcut
script.js
document.addEventListener('keydown', function(event) {
// cmdキーが押されているかのチェック
if (event.metaKey) {
if (event.keyCode === 82) {//r
var elements = document.getElementsByClassName("random-jump-button");
elements[0].click();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else if (event.keyCode === 66) {//
// ページをback
window.history.back();
}
}
});
browser speech
script.js/* speechAPIの発音 */
scrapbox.PageMenu.addMenu({
title: 'pronounce on browser',
image: 'https://scrapbox.io/files/661c7758df12b200259a22eb.png',
onClick: () => {
let hoge = scrapbox.Page.title + "";
let utterance = new SpeechSynthesisUtterance(hoge);
utterance.lang = "en-US"
window.speechSynthesis.speak(utterance);
}
});
history back
script.js/* historyバック */
scrapbox.PageMenu.addMenu({
title: 'history.back',
image: 'https://scrapbox.io/files/661c76d452e64200264217c3.png',
onClick: () => {
window.history.back();
}
});
未使用
hoge.js
/* google検索の発音 */
/*
scrapbox.PageMenu.addMenu({
title: 'google',
image: 'https://scrapbox.io/files/6614f6503cc3ec002486af00.png',
onClick: () => {
let hoge = scrapbox.Page.title + " pronunciation";
window.open(`https://www.google.com/search?q=${encodeURIComponent(hoge)}`,'pronounce');}
});*/