import { takeCursor } from "../scrapbox-userscript-std/dom.ts"; const staticStyle = document.createElement("link"); staticStyle.rel = "stylesheet"; staticStyle.href = "/api/code/takker/行末にリターン記号を表示するUserCSS/style.css"; document.head.append(staticStyle); const style = document.createElement("style"); document.head.append(style); let animationId: number | undefined; const cursor = takeCursor(); cursor.addChangeListener(() => { const { line, char } = cursor.getPosition(); const isLast = cursor.lines[line].text.length === char; if (animationId !== undefined) cancelAnimationFrame(animationId); animationId = requestAnimationFrame(() => { style.textContent = `${isLast ? `.line:nth-of-type(${line + 1}) :is(:not(.code-block.start) > .indent:not(:has(br), .cell-text, .tab), .text:not(:has(.indent)) span:has(> .char-index):not(:has(br)):last-of-type, .code-block-start > span:first-of-type, .line-title .text):after, .line:nth-of-type(${line + 1}) :is(.c-0:has(br.empty-char-index), .indent:has(> br), .cell:last-of-type .tab):before` : `.line:nth-of-type(${line + 1}) .c-${char}`} { background-color: var(--vim-cursor-bg, hsla(38.8, 100%, 50%, 0.5)); }`; }); });