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window.open(window.location.href.replace('scrapbox.io/', 'scrapbox.io/api/pages/')) ,
});
code:script.js
(() => {
let enabled = false;
function pasteTransformer() {
if (enabled === false) {
document.getElementById("text-input").addEventListener("paste", function(event) {
const clipboardText = event.clipboardData.getData("text");
function validator(x){
const isURL = /^a-z+:\/\//.test(x); const hasTextAnchor = x.includes("#:~:text=");
return isURL && hasTextAnchor;
}
if (!validator(clipboardText)) return;
// 変換処理
function modifier(x){
return x
.replace(/%2D/g, "%252D")
.replace(/%26/g, "%2526")
.replace(/%2C/g, "%252C");
}
event.preventDefault();
console.log(modifier(clipboardText));
document.execCommand("insertText", false, modifier(clipboardText));
});
enabled = true;
}
}
pasteTransformer();
scrapbox.on("page:changed", pasteTransformer);
})();
code:script.js
scrapbox.PopupMenu.addButton({
title: 'Ask LLM',
onClick: (text) => {
}});
code:script.js
scrapbox.PageMenu().addItem({
title: 'jump to calendar',
onClick: async () => {
const currentUrl = window.location.href;
const urlHash = currentUrl.split('#')1; if (urlHash) {
const apiUrl = currentUrl.replace('scrapbox.io/', 'scrapbox.io/api/pages/').split('#')0; try {
const response = await fetch(apiUrl);
const data = await response.json();
const matchingLine = data.lines.find(line => line.id === urlHash);
if (matchingLine) {
const updatedDate = new Date(matchingLine.updated * 1000);
// 日付をフォーマット
const year = updatedDate.getFullYear();
const month = updatedDate.getMonth() + 1;
const date = updatedDate.getDate();
const hours = String(updatedDate.getHours()).padStart(2, '0');
const minutes = String(updatedDate.getMinutes()).padStart(2, '0');
const formattedDate = ${year}/${month}/${date};
const timeHash = #${hours}:${minutes};
const calendarUrl = https://calendar.google.com/calendar/u/0/r/day/${formattedDate}${timeHash};
window.open(calendarUrl, '_blank');
return;
}
} catch (error) {
console.error('Error fetching page data:', error);
}
}
// fallback
const dateLabel = document.querySelector('.updated .date-label');
if (dateLabel) {
const formattedDate = dateLabel.title.split(" ")0; // fallback 時刻: 現在の時刻
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const timeHash = #${hours}:${minutes};
const calendarUrl = https://calendar.google.com/calendar/u/0/r/day/${formattedDate}${timeHash};
window.open(calendarUrl, '_blank');
}
},
});
code:script.js
scrapbox.PageMenu().addItem({
title: 'Drawing',
});
code:script_.js
code:script_.js
scrapbox.PageMenu().addItem({
title: 'Search by title',
onClick: () => {
const link = document.createElement("a")
link.href = /${scrapbox.Project.name}/search/page?q=${scrapbox.Page.title}
document.body.append(link)
link.click()
link.remove()
},
});
code:script.js
function searchTitle(){
if ($('.search-with-title-custom').length != 0) {
return
}
const input_tag = document.querySelector('.related-page-list .toolbar .related-page-list-search input')
input_tag.addEventListener('keydown', function(event) {
// Enterキーが押されたかを確認
if (event.key === 'Enter') {
const link = document.createElement("a")
link.href = /${scrapbox.Project.name}/search/page?q=${scrapbox.Page.title}+${input_tag.value} // 必要なら行IDも追記する
document.body.append(link)
link.click()
link.remove()
}
});
input_tag.classList.add('search-with-title-custom');
}
window.scrapbox.addListener("layout:changed", () => {searchTitle()});
window.scrapbox.addListener("page:changed", () => {searchTitle()});
code:script.js
$('.status-bar').append('<div aria-describedby="private-icon"><span class="item"><a href="/himitsu-untitled" target="_blank" style="color: var(--tool-text-color, #666874);"><span class="kamon kamon-unlocked"></span></a></span></div>') code:script.js
$('.status-bar').append('<div class="play-icon" style="display:none;" aria-describedby="private-icon"><span class="item"><a style="color: var(--tool-text-color, #666874);"><span class="kamon kamon-play"></span></a></span></div>') $('.status-bar').append('<div class="stop-icon" style="display:none;" aria-describedby="private-icon"><span class="item"><a style="color: var(--tool-text-color, #666874);"><span class="kamon kamon-rect"></span></a></span></div>'); code:script.js
let interval_triger = 2800
let interval_change = 10000
// resetは廃止
// startとストップ
// startはホーム画面で条件を満たした時
// ストップは
// startの前にまず,クリアをかなrず入れること
let timer_triger;
let timer_change;
function temp(){
timer_change = setInterval(movepage,interval_change);
movepage();
}
function stop_(){
clearInterval(timer_change);
clearTimeout(timer_triger);
console.log("stop")
}
function stop(){
if ( timer_change != null || timer_triger != null) {
stop_();
$('.play-icon').hide()
$('.stop-icon').show()
timer_change = null;
timer_triger = null;
hsetTimeout(()=>{$('.stop-icon').hide()},3000)
}
}
function start(){
$('.play-icon').show()
stop_();
$('.stop-icon').hide()
timer_triger = setTimeout(temp,interval_triger);
}}
const isnotDrop = Array.from(document.querySelectorAll('.dropdown-menu')).every(menu => {
return window.getComputedStyle(menu).display === 'none';
});
if(window.scrollY === 0 && isnotDrop){
start();
}else{
stop();
}
}
//window.addEventListener('focus', function(){
//start()
//});
const observer = new MutationObserver(() => {
start()
});
observer.observe(document.getElementsByTagName('title')0, {childList: true}); document.addEventListener('mousemove', stop);
document.addEventListener('keypress', stop);
document.addEventListener('scroll', stop);
document.addEventListener('click', (event)=>{
const clickedElement = event.target;
if (!(clickedElement.classList.contains('random-jump-button'))) {
stop();
}
});
window.addEventListener('blur', function(){
stop();
});
window.addEventListener('popstate', function(event) {
stop();
});
let d;
function getd(ds){
d = ds
}
let p = location.href.match(/scrapbox.io\/(^\/.*)/)1; $.getJSON("/api/pages/" + p + "?limit=1000", getd)
// 10秒間操作がないときに実行される関数
function movepage() {
let i = Math.floor(Math.random() * d.pages.length);
let random_url = "/" + p + "/" + d.pagesi.title.replace(/\//g, "%" + "2f"); const link = document.createElement("a")
link.classList.add("random-jump-button");
link.href = random_url
document.body.append(link)
link.click()
link.remove()
}else{
clickRandomButton()
}
}
function clickRandomButton() {
const button = $('.random-jump-button')
if (!button) return
}
LogseqのようにTODOを追加する
code:script.js
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);
}
document.addEventListener('keydown', function(event) {
// Macの場合はevent.metaKeyをチェックし、Windowsの場合はevent.ctrlKeyをチェック
if (event.key === 'Enter' && event.metaKey) {
// ここにCmd + Enterが押された時の処理を書く
}
})
code:script.js
$('.page-list-status .item').wrap('<a style="color: var(--tool-text-color, #666874" href="/untitled/Scrapbox_Siba">') }
const observer2 = new MutationObserver(() => {
$('.page-list-status .item').wrap('<a style="color: var(--tool-text-color, #666874" href="/untitled/Scrapbox_Siba">') }
});
observer2.observe(document.getElementsByTagName('title')0, {childList: true}); code:script.js
/** カーソルが行頭になくてもTabでインデントするUserScriptを起動する
*
* @return {() => void} scriptを解除する関数
*/
export const setup = () => {
registListener();
// @ts-ignore
scrapbox.on("layout:changed", registListener);
// @ts-ignore
return () => scrapbox.off("layout:changed", registListener);
};
/** #text-inputがあるときのみlistenerを登録する
*
* @return {void}
*/
const registListener = () => {
const textInput = document.getElementById("text-input");
if (!textInput) return;
textInput.addEventListener("keydown", operateIndent);
};
/** Tabでindent, Shift+Tabでoutdent
*
* 重複登録を防止するため、不変なobjectとして定義している
*
* @param {KeyboardEvent} e
* @return {void}
*/
const operateIndent = (e) => {
if (e.key !== "Tab") return;
const cursorLine = document.getElementsByClassName("cursor-line")0; if((cursorLine?.getElementsByClassName?.("code-block")?.length ?? 0) !== 0) return;
if((cursorLine?.getElementsByClassName?.("table-block")?.length ?? 0) !== 0) return;
if(document.getElementsByClassName("popup-menu").length !== 0) return;
const textInput = document.getElementById("text-input");
if (!textInput) return;
if (!(textInput instanceof HTMLTextAreaElement)) return;
e.preventDefault();
e.stopPropagation();
press(e.shiftKey ? 37 : 39, textInput, { ctrlKey: true });
};
const press = (keyCode, textInput, pressOptions) => {
const { noModifiedKeys = false, ...rest } = pressOptions ?? {};
const options = {
bubbles: true,
cancelable: true,
keyCode,
...(noModifiedKeys ? {} : { ...rest }),
};
textInput.dispatchEvent(new KeyboardEvent("keydown", options));
textInput.dispatchEvent(new KeyboardEvent("keyup", options));
};
setup();
code:script.js
(() => {
$('#text-input').on('keydown', e => {
if (e.keyCode != 13) return true;
if ($('.cursor-line .code-block').length != 0) return true;
if ($('.cursor-line .table-block').length != 0) return true;
if ($('.popup-menu').length != 0) return true;
const children = document.querySelector('.cursor-line .indent').childNodes;
if (!(children.length === 1 && children0.nodeName === 'BR')) return true; let keydown = document.createEvent('Events');
keydown.initEvent('keydown', true, true);
keydown.keyCode = e.which = (9);
keydown.shiftKey = true;
$('#text-input')0.dispatchEvent(keydown); return false;
});
})();
code:script.js
let enabled = false;
function foajofia(){
if (enabled === false){
document.getElementById("text-input").addEventListener("paste", function(event) {
const clipbordText = event.clipboardData.getData("text");
// http/https 以外のスキーマ:// を持つURLだけ対象
function validator(x){
const match = x.match(/^(a-z+):\/\//); if (match) {
const protocol = match1.toLowerCase(); return protocol !== "http" && protocol !== "https";
} else {
return false;
}
}
if (!validator(clipbordText)) return;
function modifier(x){
return http://localhost/${x};
}
event.preventDefault();
document.execCommand("insertText", false, modifier(clipbordText));
});
enabled = true;
}
}
foajofia();
scrapbox.on("page:changed", foajofia);
code:script.js
function moveUp(){
var event = new KeyboardEvent('keydown', {
key: 'ArrowUp', // 上矢印キーを指定
code: 'ArrowUp',
keyCode: 38, // 上矢印キーのkeyCode
shiftKey: true, // Shiftキーが押されていることを示す
bubbles: true, // イベントがバブルアップするように設定
cancelable: true
});
document.querySelector('.text-input').dispatchEvent(event);
}
function moveRight(){
var event = new KeyboardEvent('keydown', {
key: 'ArrowRight', // 右矢印キーを指定
code: 'ArrowRight',
keyCode: 39, // 右矢印キーのkeyCode
metaKey: true, // Cmdキーが押されていることを示す
bubbles: true, // イベントがバブルアップするように設定
cancelable: true
});
document.querySelector('.text-input').dispatchEvent(event);
}
function moveLeft(){
var event = new KeyboardEvent('keydown', {
key: 'ArrowLeft', // 左矢印キーを指定
code: 'ArrowLeft',
keyCode: 37, // 左矢印キーのkeyCode
metaKey: true, // Cmdキーが押されていることを示す
shiftKey: true, // Shiftキーが押されていることを示す
bubbles: true, // イベントがバブルアップするように設定
cancelable: true
});
document.querySelector('.text-input').dispatchEvent(event);
}
scrapbox.PopupMenu.addButton({
title: 'headhing',
onClick: text => {
console.log(text);
} else {
if (!/\n/.test(text)){
moveRight();
}
moveLeft();
moveUp();
setTimeout(() => {
document.querySelector("#editor > div.selections > div.popup-menu > div.button-container").childNodes.forEach(element => {
if (element.innerText === "headhing") {
// クリックイベントを発火
element.click();
}
});
}, 0) // カーソルの移動を待機するため
}
}
});
code:script.js
scrapbox.PopupMenu.addButton({
title: 'H_newpage',
onClick: text => {
const lines = text.split(/\r\n/g) .trim()
.replace(/\^\+.icon\]/gm, '')
const projectRoot = (() => {
const tmp = location.href.split('/')
tmp.pop()
return tmp.join('/')
})()
const fotter = (() => {
const elements = document.querySelectorAll('.line'); // 'selector' は目的の要素を指定
for (let i = elements.length - 1; i >= 0; i--) {
const element = elementsi; if (element.textContent.includes("from")) {
console.log("fdsfa")
return element.textContent;
}
}
})();
const currentPageTitle = decodeURIComponent(location.href.split(/\//g).pop())
lines.shift()
const body = encodeURIComponent(lines.concat([from [${currentPageTitle}],fotter]).join('\n'))
console.log(${projectRoot}/${title}?body=${body})
return [${title}]
}
});
window.open(${projectRoot}/${title}?body=${body})
code:script.js
$('button.btn-search').after('<button tabindex="-1" type="button" class="btn-cross-circle focus"><svg class="kamon"><use xlink:href="/assets/sprite.svg#cross-circle"></use></svg></button>');
document.querySelector(".search-form .btn-cross-circle").addEventListener('mousedown', function(event) { // 入力フィールドにフォーカスを戻す
event.preventDefault();
document.querySelector(".form-control").value = ""
});
code:script_.js
document.querySelector('.form-control.for-mobile').addEventListener('click', function() {
if (document.querySelector('.form-control.for-mobile').value == ""){
document.querySelector('.form-control.for-mobile').value = scrapbox.Page.title
}
});
code:script_.js
scrapbox.on("page:changed",()=>{document.querySelector('.form-control.for-mobile').value = scrapbox.Page.title})
scrapbox.on("layout:changed",()=>{document.querySelector('.form-control.for-mobile').value = scrapbox.Page.title})
code:script_.js
(() => {
const inputs = document.querySelectorAll('.search-form input');
scrapbox.on("page:changed", () => { input.value = scrapbox.Page.title });
scrapbox.on("layout:changed", () => { input.value = scrapbox.Page.title });
input.addEventListener('click', function () {
if (input.value == "") {
input.value = scrapbox.Page.title
}
});
})();
code:script.js
scrapbox.PageMenu.addItem({
title: () => search google,
onClick: () => window.open(https://www.google.co.jp/search?q=${scrapbox.Page.title})
});
code:script.js
(() => {
function main() {
if ($('.google-search-suggest').length != 0) {
return
}
const query = decodeURIComponent(document.URL.match(/\?q=(^&*)/)1); $('.search-result-list > .project-search').before(`
<ul class="list create-searched-page google-search-suggest" style = "margin-top: 60px;">
<li class="page-list-item list-style-item" ><a
<div class="icon kamon-icon"><span class="kamon kamon-sparkles"></span></div>
<div class="content">
<div class="title-with-description">Google "${query}"</div>
</div>
</a></li>
</ul>`)
}
}
main()
const observer = new MutationObserver(() => {
main()
});
observer.observe(document.getElementsByTagName('title')0, { childList: true }); })();
code:script_.js
document.querySelector('.project-home').href = "/untitled/box"
$('button.btn-search').after('<button class="btn-search custom" ><a style="line-height: 0;" href="/untitled/"><svg class="kamon"><use xlink:href="/assets/sprite.svg#home"></use></svg></a></button>')
document.querySelector('button.btn-search:not(.custom)').style = "display:none"
code:script.js
document.addEventListener('keydown', function(event) {
if (event.ctrlKey && event.key === 'Enter') {
const cursor = document.querySelector('.cursor').getBoundingClientRect();
// イベントを任意のターゲットに送信(例: document)
document.elementFromPoint(cursor.x-5,cursor.y).closest('a').click()
document.dispatchEvent(new KeyboardEvent('keydown', {
key: 'Escape', // ESCキー
code: 'Escape',
keyCode: 27, // ESCキーのキーコード
bubbles: true // イベントがバブリングするように設定
}));
}
});
code:script.js
(() => {
const cursor = document.querySelector('.cursor-container .cursor');
// クリックイベントでアニメーションをリセット
cursor.addEventListener("click", resetAnimation);
// キー入力イベントでアニメーションをリセット
document.addEventListener("keydown", resetAnimation);
function resetAnimation() {
// アニメーションをリセット
cursor.style.animation = "none";
// 強制的に再描画
void cursor.offsetWidth;
// 再度アニメーションを適用
cursor.style.animation = "blink 1s infinite";
}
})();
code:script_.js
(() => {
const observer = new MutationObserver(() => {
const target = document.querySelector(".telomere-border .menu-item:nth-child(4)");
if (target) {
// <a>タグを作成
const link = document.createElement('a');
link.target = '_blank'; // 任意:新しいタブで開く
// 元の要素を<a>の中に移動
target.parentNode.insertBefore(link, target); // 元の位置に<a>を挿入
link.appendChild(target); // <span>を<a>の子要素にする
}
});
observer.observe(document.querySelector('.telomere-border'), { childList: true, subtree: true });
})();
code:script.js
(() => {
function main() {
// SVG内のすべての<line>要素を取得
const svgs = document.querySelectorAll('.lines svg');
// 各<line>要素を処理
svgs.forEach(svg => {
// 2. SVG を文字列にシリアライズ
const svgString = new XMLSerializer().serializeToString(svg);
// 3. Blob を作成
const blob = new Blob(svgString, { type: 'image/svg+xml' }); // 4. Blob の URL を作成
const blobURL = URL.createObjectURL(blob);
// 5. <img> タグを作成して置換
const img = document.createElement('img');
img.src = blobURL;
img.width = svg.clientWidth;
img.height = svg.clientHeight;
// 6. SVG を置換
svg.replaceWith(img);
});
};
main();
scrapbox.on("lines:changed",main);
scrapbox.on("page:changed",main)
})();