kitasenjudesign
my name is kitasenju design.
userscript
code:script.js
console.log(">>>>",scrapbox);
/* 英次郎&ケンブリッジへのリンクを挿入 */
scrapbox.PageMenu.addMenu({
title: 'insert eijiro/cambridge link',
onClick: () => {
let hoge = encodeURIComponent(scrapbox.Page.title) + "";
}
});
/* speechAPIの発音 */
scrapbox.PageMenu.addMenu({
title: 'pronounce on browser',
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',
onClick: () => {
let title = encodeURIComponent(scrapbox.Page.title) + "";
}
});
/* ukonowへのリンクを挿入 */
scrapbox.PageMenu.addMenu({
title: '類似',
onClick: () => {
let title = encodeURIComponent(scrapbox.Page.title) + "";
}
});
/* ----------------------------- */
/* ページ変更の監視 と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");
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);
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',
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',
onClick: () => {
window.history.back();
}
});
openAI
code:script.js
/* historyバック */
scrapbox.PageMenu.addMenu({
title: 'openai',
onClick: () => {
let hoge = encodeURIComponent(scrapbox.Page.title)
}
});
未使用
code:hoge.js
/* google検索の発音 */
/*
scrapbox.PageMenu.addMenu({
title: 'google',
onClick: () => {
let hoge = scrapbox.Page.title + " pronunciation";
window.open(https://www.google.com/search?q=${encodeURIComponent(hoge)},'pronounce');}
});*/