quicksearchをアドレスバーにする
code:script.js
function updateAddressBar() {
document.querySelector("input.form-control").value = scrapbox.Page.title;
}
document.querySelector("input.form-control").addEventListener("focus", () => {
setTimeout(() => {
updateAddressBar();
document.querySelector("input.form-control").select();
}, 200);
});
document.querySelector("input.form-control").addEventListener("blur", () => {
setTimeout(updateAddressBar, 200);
});
document
.querySelector("input.form-control")
.addEventListener("keydown", (e) => {
// 13はEnterキーのキーコード
if (event.isComposing || event.keyCode === 229) {
return;
}
if (e.code == "Enter") {
e.preventDefault();
// setTimeout(()=>{
let value = document.querySelector("input.form-control").value;
if (document.querySelector(".footer .kamon-locked") == null) {
window.open(
);
} else {
window.open(
"/" +
scrapbox.Project.name +
"/search/page?q=" +
encodeURIComponent(value.slice(1)),
);
}
} else {
let linkto = document.createElement("a");
if (value == "") {
linkto.href = "/" + scrapbox.Project.name + "/new";
} else {
linkto.href =
"/" + scrapbox.Project.name + "/" + encodeURIComponent(value);
}
document.body.append(linkto);
linkto.click();
linkto.remove();
document.querySelector("input.form-control").blur();
}
// },1000);
}
});
scrapbox.on("page:changed", updateAddressBar);
scrapbox.on("layout:changed", updateAddressBar);
updateAddressBar();