kitasenjudesign
my name is kitasenju design.
contact = https://kitasenjudesign.com/
userscript
how to use userScript 👉 /help-jp/UserScript
reference /takker/scrapbox-insert-text
code:script.js
console.log(">>>>",scrapbox);
/* 英次郎&ケンブリッジへのリンクを挿入 */
scrapbox.PageMenu.addMenu({
title: 'insert eijiro/cambridge link',
image: 'https://scrapbox.io/files/6616066cf226080024a3f40d.png',
onClick: () => {
let hoge = encodeURIComponent(scrapbox.Page.title) + "";
insertText("\n⬆️️:"+scrapbox.Page.title+"\n");
insertText("🌎️️:"+scrapbox.Page.title+"\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("【辞】⬆️️:"+scrapbox.Page.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("🐵:"+scrapbox.Page.title+"\n");
insertText("📣:"+scrapbox.Page.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
code:script.js
document.addEventListener('keydown', function(event) {
// cmdキーが押されているかのチェック
if (event.altKey) {
if (event.keyCode === 82) {//r
var elements = document.getElementsByClassName("random-jump-button");
elements0.click();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else if (event.keyCode === 66) {//
// ページをback
//window.alert("aa");
window.history.back();
} else if (event.KeyCode === 65 ){//L
window.alert("aa");
// <section class="related-page-list"/> 要素を取得
const section = document.querySelector('section.related-page-list');
// セクション以下のすべての aタグ を取得
const links = section ? section.querySelectorAll('a') : [];
// ランダムに1つ選んでそのリンクにジャンプ
if (links.length > 0) {
const randomIndex = Math.floor(Math.random() * links.length);
const randomLink = linksrandomIndex;
randomLink.click();
const url = randomLink.href;
// 実際にそのリンクに移動
window.location.href = url;
} else {
console.log('リンクが見つかりませんでした');
}
}////
}
});
browser speech
code: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
code:script.js
/* historyバック */
scrapbox.PageMenu.addMenu({
title: 'history.back',
image: 'https://scrapbox.io/files/661c76d452e64200264217c3.png',
onClick: () => {
window.history.back();
}
});
openAI
code:script.js
/* historyバック */
scrapbox.PageMenu.addMenu({
title: 'openai',
image: 'https://gyazo.com/f7f0dd5eb1a8a2b1780e275fa9626988.png',
onClick: () => {
let hoge = encodeURIComponent(scrapbox.Page.title)
window.open("https://chat.openai.com/?q="+hoge+"の英語の例文をつくって");
}
});
未使用
code: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');}
});*/
#member