When focusing the textarea, click the bookmarklet, and use document.activeElement
to identify the textarea, and .slice
its value, concatenating with window.location.origin
:
(当集中文本区域时,单击小书签,并使用document.activeElement
标识文本区域,并对其值进行.slice
,并与window.location.origin
串联:)
javascript: (() => {
const textarea = document.activeElement;
const { selectionStart } = textarea;
textarea.value = textarea.value.slice(0, selectionStart) + window.location.origin + textarea.value.slice(selectionStart);
})();
If you want the bookmarklet to work for the iframe inside https://robot-parts.confetti.events/
, then access the contentWindow.document
to get to the activeElement
:
(如果您希望小书签在https://robot-parts.confetti.events/
的iframe中起作用, https://robot-parts.confetti.events/
访问contentWindow.document
进入activeElement
:)
javascript: (() => {
const textarea = document.querySelector('.signup-iframe').contentWindow.document.activeElement;
const { selectionStart } = textarea;
textarea.value = textarea.value.slice(0, selectionStart) + window.location.origin + textarea.value.slice(selectionStart);
})();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…