- Extension to use Keicho with Scrapbox PopupMenu asking [/takker/selection to Keicho](https://scrapbox.io/takker/selection to Keicho).
- Tried the
Iāll copy and paste the version as of 2021-07-29 and run it. js
https://scrapbox.io/api/code/nishio/scrapbox-insert-text-2/script.js net::ERR_ABORTED 404 (Not Found)
Thatās right, fix to absolute paths.
Uncaught (in promise) ReferenceError: getTalkId is not defined
I missed that there are two scripts.
Uncaught (in promise) SyntaxError: Unexpected token ')'
Merge and extract the code block of the same name in the page of /takker/scrapbox.
Corrected by copying and pasting from
Uncaught (in promise) ReferenceError: askKeicho is not defined
Put the following UserScript in TamperMonkey.
test keicho.json
What kind of ātestā is this ātestā? Whoa, now I can talk to Keicho on Scrapbox! What kind of āKeichoā is this āKeichoā?
As already written in [/takker/UserScript to chat with Keicho](https://scrapbox.io/takker/UserScript to chat with Keicho), āI want to send answers without making selections / with one button or one keystroke.ā
- I donāt have to make a selection to access the entire page content.
- How about creating something like
[ask_keicho.icon]
, and using a hotkey to enter the non-empty line before the icon, and inserting the answer before the icon? 1
Test (cursor)[ask_keicho.icon]
2
test
[nisbot.icon]What kind of "test" is this "test"?
(cursor)[ask_keicho.icon]
2
test
[nisbot.icon]What kind of "test" is this "test"?
Next sentence (cursor)[ask_keicho.icon]
-
Would you rather this be āthe line with the cursorā?
- Image of hotkey becoming āask me a question line breakā.
-
Right now Keicho has a chat-like UI that looks human and behaves in a tightly coupled āonly put a quote when asking a question in a sentence other than the one immediately preceding itā, but you can always include the input text in the response.
- Then the UserScript side can look at it and decide where to insert itā¦?
- Iām still trying to figure out how the asynchronous text in Scrapbox works.
- Ah, youāre using a textarea inserted at the cursor position, then I can only write at the userās cursor position.
- This is going to be difficult because of Scrapboxās philosophy of not providing an API for programs to write to arbitrary locations, so the user will have to move it themselves.
- Then the UserScript side can look at it and decide where to insert itā¦?
-
line containing the cursor
- Wow, Textarea is floating with position: absolute?
- XPath
$x("//span[@class='text' and contains(.,'[ask_keicho.icon]')]").slice(-1)[0].innerText
"\t\n Why don't you create something like [ask_keicho.icon] separately from [nisbot.icon], use the hotkey to take the non-empty line before that icon as input, and insert the answer before the icon."
- https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate
document.evaluate("//span[@class='text' and contains(.,'[ask_keicho.icon]')]", document).iterateNext().innerText
Itās an icon, so canāt you get it with this? ā False.
-
document.querySelector("span.text img[alt='ask_keicho']").parentElement.parentElement.parentElement.parentElement.innerText
-
Incorrect: When the cursor is in front of the icon, the line is in edit mode, so it is text.
-
Activate by pressing CTRL+Enter
- Oopsā¦
- Keichoās specification that interprets keywords enclosed in square brackets as explicit keywords.
- So letās just call it
(keicho)
then.
Itās done. - Ctrl+Enter in Scrapbox to have Keicho ask a question.
This page is auto-translated from /nishio/éøęēÆå²ćKeichoć«å°ććPopupMenu using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. Iām very happy to spread my thought to non-Japanese readers.