重现步骤:
- 使用 Google Chrome 导航至https://www.reddit.com/r/RetroArch/comments/7m8wlo/issues_with_nvidia_shield_controller_shield_tv/
- 使用CTRL+f向前搜索“尝试卸载 Retroarch”。
- 选择相同的文本,单击鼠标右键,然后尝试选择复制链接以突出显示。请注意,它是灰色的(表示已停用);见下面的屏幕截图。
将此与 SuperUser 等其他网站进行比较,该功能有效:https://superuser.com/questions/61069/how-can-i-disable-selected-windows-7-keyboard-shortcuts#:~:text=return%22%20on%20its-,own%20line%20at%20the%20end,-of%20the%20script
我尝试了许多其他 Reddit 页面,它们都成功导致 Chrome 停用复制链接以突出显示特征。
我猜测该网站本身可能会以某种方式导致 Chrome 停用该菜单项;这里的情况是这样吗?如果是这样,他们是如何做到的?
我在 Microsoft Windows 10 上运行的浏览器版本:版本 96.0.4664.93(官方版本)(64 位)
此缺陷也在运行于 Ubuntu Linux 20.04 的 Google Chrome 上重现。
答案1
转到
chrome://flags/#shared-highlighting-use-blocklist
并将其设置为已禁用。只要 Chrome 开发人员不决定删除此选项,这将解决问题。
该设置描述如下:
使用黑名单禁用某些网站上的共享突出显示链接生成,在这些网站上,个性化或动态内容或其他技术限制使得 URL 不太可能在共享时生成并实际起作用。– Mac、Windows、Linux、Chrome OS、Android
编辑:
chrome://flags/#shared-highlighting-use-blocklist
最近已被弃用,但可能被改为
chrome://flags/#shared-highlighting-refined-blocklist
定义为:
缩小启用共享突出显示的阻止列表。– Mac、Windows、Linux、ChromeOS、Android、Fuchsia、Lacros
答案2
谷歌的文本片段链接 扩大更通用。例如:
生成http://web.archive.org/web/20171213212419/http://vim.1045645.n5.nabble.com/dump-register-to-file-without-open-td1170411.html#:~:text=open%2Fput%20is-,更简单可以正常工作。
((它的自动片段生成有点冗长,没有必要:突出显示的单词simpler
在页面上是唯一的,因此片段链接在没有上下文的open/put is
情况下也可以正常工作:http://web.archive.org/web/20171213212419/http://vim.1045645.n5.nabble.com/dump-register-to-file-without-open-td1170411.html#:~:text=simpler))
(不幸的是,谷歌不再允许您删除原始的Copy link to highlight
上下文菜单条目。[参考]因此添加扩展意味着会变得更加混乱。)
不幸的是,根据我的谷歌搜索,在需要唯一标识时自动添加上下文(prefix-
,-postfix
)的更高级功能似乎在书签小工具。如果您不需要该功能,您可以使用例如这个书签:
javascript:(function()%7Bfunction%20getSelectionText()%20%7B%0A%20var%20selectedText%20%3D%20%22%22%0A%20if%20(window.getSelection)%20%7B%20%2F%2F%20all%20modern%20browsers%20and%20IE9%2B%0A%20selectedText%20%3D%20window.getSelection().toString().trim()%3B%0A%20%09selectedText%20%3D%20encodeURIComponent(selectedText)%3B%0A%20%7D%0A%20return%20selectedText%3B%0A%7D%0Avar%20text%20%3D%20getSelectionText()%3B%0Avar%20bookmarklet_version%20%3D%20%221.1%22%3B%0Aif%20(typeof%20text%20%3D%3D%20%22undefined%22%20%7C%7C%20text%20%3D%3D%20%22%22)%20%7B%0A%20alert(%22Please%20select%20some%20text.%22)%3B%0A%7D%20else%20%7B%0A%20var%20style%20%3D%20document.createElement('style')%3B%0A%20style.innerHTML%20%3D%0A%20'%23supple-text-bookmarklet-5646%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'margin%3A%200%3B'%20%2B%0A%09%20'color%3A%20%230f0f0f%3B'%20%2B%0A%09%20'padding%3A%200%3B'%20%2B%0A%09%20'border%3A%200%3B'%20%2B%0A%09%20'font-size%3A%20100%25%3B'%20%2B%0A%09%20'font%3A%20inherit%3B'%20%2B%0A%09%20'vertical-align%3A%20baseline%3B'%20%2B%0A%09%20'position%3A%20fixed%3B'%20%2B%0A%09%20'background-color%3Awhite%3B'%20%2B%0A%09%20'width%3A550px%3B'%20%2B%0A%09%20'font-size%3A12px%3B'%20%2B%0A%09%20'right%3A%205px%3B'%20%2B%0A%09%20'border-width%3A%201px%3B'%20%2B%0A%09%20'border-style%3A%20solid%3B'%20%2B%0A%09%20'border-color%3A%20rgb(169%2C%20169%2C%20169)%3B'%20%2B%0A%09%20'border-image%3A%20initial%3B'%20%2B%0A%09%20'padding%3A%2015px%3B'%20%2B%0A%09%20'bottom%3A%205px%3B'%20%2B%0A%09%20'z-index%3A%20'%2BNumber.MAX_SAFE_INTEGER%2B'%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-5646%20h4%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'padding%3A%200%3B'%20%2B%0A%09%20'font-size%3A%2020px%3B'%20%2B%0A%09%20'font-weight%3A%20600%3B'%20%2B%0A%09%20'margin%3A%200%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-close-5646%20%7B'%20%2B%0A%09%20'display%3A%20block%3B'%20%2B%0A%09%20'position%3A%20absolute%3B'%20%2B%0A%09%20'top%3A%200px%3B'%20%2B%0A%09%20'padding%3A%208px%2010px%3B'%20%2B%0A%09%20'right%3A%200px%3B'%20%2B%0A%09%20'cursor%3A%20pointer%3B'%20%2B%0A%09%20'font-size%3A%2011px%3B'%20%2B%0A%09%20'font-weight%3A%20bold%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-5646%20%3Ediv%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'padding%3A%2015px%200%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-5646%20%3Ediv%3Ediv%3Ediv%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'font-size%3A11px%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-5646%20button%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'padding%3A%205px%3B'%20%2B%0A%09%20'margin%3A%2010px%200%3B'%20%2B%0A%09%20'font-size%3A12px%3B'%20%2B%0A%09%20'color%3A%20%23fff%3B'%20%2B%0A%09%20'background-color%3A%20%230095ff%3B'%20%2B%0A%09%20'border-color%3A%20%230095ff%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-5646%20button.moreOptions%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'padding%3A%205px%3B'%20%2B%0A%09%20'float%3A%20right%3B'%20%2B%0A%09%20'margin%3A%200%3B'%20%2B%0A%09%20'color%3A%20%230095ff%3B'%20%2B%0A%09%20'background-color%3A%20%23fff%3B'%20%2B%0A%09%20'border-color%3A%20%230095ff%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-result-5646%20%7B'%20%2B%0A%09%20'display%3A%20none%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-adv-5646%20%7B'%20%2B%0A%20%09'clear%3A%20both%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'.supple-text-bookmarklet-adv-container%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'margin%3A%205px%200%3B'%20%2B%0A%09%20'padding%3A%205px%200%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'.supple-text-bookmarklet-label%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'float%3A%20none%3B'%20%2B%0A%09%20'font-size%3A12px%3B'%20%2B%0A%09%20'width%3A%20100px%3B'%20%2B%0A%09%20'display%3A%20inline-block%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'.supple-text-bookmarklet-input%20input%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'font-size%3A12px%3B'%20%2B%0A%09%20'width%3A%20100%25%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-credit-5646%20%7B'%20%2B%0A%09%09%20'clear%3A%20both%3B'%20%2B%0A%09%09%20'text-align%3A%20center%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-credit-5646%20img%20%7B'%20%2B%0A%09%09%20'vertical-align%3A%20middle%3B'%20%2B%0A%09%09%20'margin%3A%200%2010px%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%23supple-text-bookmarklet-credit-5646%20a.moreinfo%7B'%20%2B%0A%09%09%09'right%3A%2020px%3B'%20%2B%0A%09%09%09'vertical-align%3A%20bottom%3B'%20%2B%0A%09%09%09'position%3A%20absolute%3B'%20%2B%0A%09%09%09'bottom%3A%2010px%3B'%20%2B%0A%20'%7D'%20%2B%0A%09%09'%23supple-text-bookmarklet-link-1%2C%20%23supple-text-bookmarklet-link-2%7B'%20%2B%0A%09%09%09'padding%3A%2010px%200%3B'%20%2B%0A%09%09%09'overflow%3A%20hidden%3B'%20%2B%0A%20'%7D'%20%2B%0A%09%09'%23supple-text-bookmarklet-link-1%20a%2C%20%23supple-text-bookmarklet-link-2%20a%7B'%20%2B%0A%09%20'color%3A%20%230095ff%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'.supple-text-bookmarklet-input%20%7B'%20%2B%0A%09%20'font-family%3A%20sans-serif%3B'%20%2B%0A%09%20'font-size%3A12px%3B'%20%2B%0A%09%20'float%3A%20right%3B'%20%2B%0A%09%20'display%3A%20inline-block%3B'%20%2B%0A%09%20'width%3A%2070%25%3B'%20%2B%0A%09%20'width%3A%20calc(100%25%20-%20120px)%3B'%20%2B%0A%20'%7D'%20%2B%0A%20'%40media%20(max-width%3A%20768px)%7B'%20%2B%0A%20%09'%23supple-text-bookmarklet-5646%20%7B'%20%2B%0A%09%20%09'max-width%3A%20100%25%3B'%20%2B%0A%09%20%09'max-width%3A%20calc(100%25%20-%2010px)%3B'%20%2B%0A%20%09'%7D'%20%2B%0A%20'%7D'%3B%0A%0A%0A%0A%2F*%0A%20border%3A%201px%20dotted%20red%3B%0A%20display%3A%20block%3B%0A%20float%3A%20right%3B%0A%20clear%3A%20both%3B%0A%20position%3A%20absolute%3B%0A*%2F%0A%09console.clear()%3B%09%0A%20var%20moreOptionsHandler%20%3D%20function()%20%7B%0A%20console.log(%22moreOptionsHandler%22)%3B%0A%20var%20advPanel%20%3D%20document.getElementById(%22supple-text-bookmarklet-adv-5646%22)%3B%0A%20if%20(advPanel)%20%7B%0A%20if%20(advPanel.style.display%20%3D%3D%20'none')%20%7B%0A%20advPanel.style.display%20%3D%20%22block%22%3B%0A%20this.innerHTML%20%3D%20%22Basic%20Options%20%26%238657%3B%22%3B%0A%20%7D%20else%20%7B%0A%20advPanel.style.display%20%3D%20%22none%22%3B%0A%20this.innerHTML%20%3D%20%22More%20Options%20%26%238659%3B%22%3B%0A%20%7D%0A%20%7D%0A%20%7D%0A%0A%20function%20copyToClipboard(text)%20%7B%0A%20var%20dummy%20%3D%20document.createElement(%22textarea%22)%3B%0A%20document.body.appendChild(dummy)%3B%0A%20dummy.value%20%3D%20text%3B%0A%20dummy.select()%3B%0A%20document.execCommand(%22copy%22)%3B%0A%20document.body.removeChild(dummy)%3B%0A%20%7D%0A%0A%20var%20copyClickEvent%20%3D%20function()%20%7B%0A%20%2F*Event%20to%20be%20fired%20upon%20btn%20click%20*%2F%0A%20copyToClipboard(this.getAttribute('link'))%3B%0A%20var%20elm%20%3D%20this%3B%0A%20console.log(%22Copied%3A%20%22%20%2B%20this.getAttribute('link'))%3B%0A%20elm.childNodes%5B0%5D.nodeValue%20%3D%20%22Copied%22%3B%0A%20setTimeout(function()%20%7B%0A%20elm.childNodes%5B0%5D.nodeValue%20%3D%20%22Copy%20Link%22%3B%0A%20%7D%2C%20500)%3B%0A%20%7D%0A%0A%20var%20copyBtn%20%3D%20document.createElement(%22button%22)%3B%0A%20copyBtn.innerHTML%20%3D%20%22Copy%20Link%22%3B%0A%20copyBtn.addEventListener(%22click%22%2C%20copyClickEvent)%3B%0A%0A%0A%20var%20renderResult%20%3D%20function%20(resultDiv%2C%20link1%2C%20link2)%7B%0A%09%09if%20(typeof%20link1%20%3D%3D%20%22undefined%22)%20%7B%0A%09%09%09link1%20%3D%20%22%22%3B%0A%09%09%7D%0A%09%09if%20(typeof%20link2%20%3D%3D%20%22undefined%22)%20%7B%0A%09%09%09link2%20%3D%20%22%22%3B%0A%09%09%7D%0A%20%09console.log(%22link1%20%5B%22%20%2B%20link1%20%2B%20%22%5D%22)%3B%0A%20%09console.log(%22link2%20%5B%22%20%2B%20link2%20%2B%20%22%5D%22)%3B%0A%0A%09%09if%20(link1%20%3D%3D%20%22%22%20%26%26%20link2%20%3D%3D%20%22%22%20)%7B%0A%09%09%09return%20false%3B%0A%09%09%7D%0A%20%09console.log(%22renderResult%20link1%3A%20%22%20%2B%20link1%20%2B%20%22%20link2%3A%20%22%20%2B%20link2)%3B%0A%0A%0A%20var%20link1Div%20%3D%20document.getElementById(%22supple-text-bookmarklet-link-1%22)%3B%0A%20if%20(!link1Div)%7B%0A%09%09%20link1Div%20%3D%20document.createElement(%22div%22)%3B%0A%09%09%20link1Div.id%20%3D%20'supple-text-bookmarklet-link-1'%3B%0A%09%09%20link1Div.style.display%20%3D%20%22none%22%3B%0A%20%7D%0A%0A%20var%20link2Div%20%3D%20document.getElementById(%22supple-text-bookmarklet-link-2%22)%3B%0A%20if%20(!link2Div)%7B%0A%09%09%20link2Div%20%3D%20document.createElement(%22div%22)%3B%0A%09%09%20link2Div.id%20%3D%20'supple-text-bookmarklet-link-2'%3B%0A%09%09%20link2Div.style.display%20%3D%20%22none%22%3B%0A%09%09%7D%0A%0A%09%20var%20copyBtn1%20%3D%20copyBtn.cloneNode(true)%3B%0A%09%20copyBtn1.id%20%3D%20'supple-text-bookmarklet-btn-1'%3B%0A%09%20copyBtn1.onclick%20%3D%20copyClickEvent%3B%0A%0A%09%20var%20copyBtn2%20%3D%20copyBtn.cloneNode(true)%3B%0A%09%20copyBtn2.id%20%3D%20'supple-text-bookmarklet-btn-2'%3B%0A%09%20copyBtn2.onclick%20%3D%20copyClickEvent%3B%0A%0A%0A%20if%20((link1%20!%3D%20link2)%20%26%26%20(link2%20!%3D%20%22%22))%20%7B%0A%20link1Div.innerHTML%20%3D%20%22%3Cstrong%3EClean%20Link%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink1%2B%22'%3E%22%20%2B%20link1%20%2B%20%22%3C%2Fa%3E%22%3B%0A%20link1Div.style.display%20%3D%20%22block%22%3B%0A%0A%20var%20copy1Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-1%22)%3B%0A%20if%20(!copy1Btn)%7B%0A%09%09%09%20var%20copy1Btn%20%3D%20copyBtn.cloneNode(true)%3B%0A%09%09%09%20copy1Btn.id%20%3D%20'supple-text-bookmarklet-btn-1'%3B%0A%09%09%09%20copy1Btn.onclick%20%3D%20copyClickEvent%3B%0A%20%7D%0A%20copy1Btn.style.display%20%3D%20%22block%22%3B%0A%20copy1Btn.setAttribute(%22link%22%2C%20link1)%3B%0A%20var%20copy2Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-2%22)%3B%0A%20if%20(!copy2Btn)%7B%0A%09%09%09%20var%20copy2Btn%20%3D%20copyBtn.cloneNode(true)%3B%0A%09%09%09%20copy2Btn.id%20%3D%20'supple-text-bookmarklet-btn-2'%3B%0A%09%09%09%20copy2Btn.onclick%20%3D%20copyClickEvent%3B%0A%20%7D%0A%20copy2Btn.style.display%20%3D%20%22block%22%3B%0A%20copy2Btn.setAttribute(%22link%22%2C%20link2)%3B%0A%0A%20link2Div.innerHTML%20%3D%20%22%3Cstrong%3EURL%20with%20parameters%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink2%2B%22'%3E%22%20%2B%20link2%20%2B%20%22%3C%2Fa%3E%22%3B%0A%20link2Div.style.display%20%3D%20%22block%22%3B%0A%20%7D%20else%20%7B%0A%20link1Div.innerHTML%20%3D%20%22%3Cstrong%3EClean%20Link%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink1%2B%22'%3E%22%20%2B%20link1%20%2B%20%22%3C%2Fa%3E%22%3B%0A%20link1Div.style.display%20%3D%20%22block%22%3B%0A%0A%0A%20var%20copy1Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-1%22)%3B%0A%20if%20(!copy1Btn)%7B%0A%09%09%09%20var%20copy1Btn%20%3D%20copyBtn.cloneNode(true)%3B%0A%09%09%09%20copy1Btn.id%20%3D%20'supple-text-bookmarklet-btn-1'%3B%0A%09%09%09%20copy1Btn.onclick%20%3D%20copyClickEvent%3B%0A%20%7D%0A%20copy1Btn.style.display%20%3D%20%22block%22%3B%0A%20copy1Btn.setAttribute(%22link%22%2C%20link1)%3B%0A%20var%20copy2Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-2%22)%3B%0A%20if%20(!copy2Btn)%7B%0A%09%09%09%20var%20copy2Btn%20%3D%20copyBtn.cloneNode(true)%3B%0A%09%09%09%20copy2Btn.id%20%3D%20'supple-text-bookmarklet-btn-2'%3B%0A%09%09%09%20copy2Btn.onclick%20%3D%20copyClickEvent%3B%0A%20%7D%0A%20copy2Btn.style.display%20%3D%20%22none%22%3B%0A%20copy2Btn.setAttribute(%22link%22%2C%20link2)%3B%0A%0A%20%7D%0A%20resultDiv.appendChild(link1Div)%3B%0A%20resultDiv.appendChild(copy1Btn)%3B%0A%20resultDiv.appendChild(link2Div)%3B%0A%20resultDiv.appendChild(copy2Btn)%3B%0A%20resultDiv.style.display%20%3D%20%22block%22%3B%0A%0A%20%7D%0A%0A%0A%20var%20advOptionsHandler%20%3D%20function()%20%7B%0A%0A%20var%20link%20%3D%20window.location.href%3B%0A%20%2F*%0A%20if%20(link.charAt(link.length%20-%201)%20!%3D%20%22%2F%22)%20%7B%0A%20link%20%2B%3D%20'%2F'%3B%0A%20%7D%0A%20*%2F%0A%0A%0A%20var%20result%20%3D%20%22%23%3A~%3Atext%3D%22%3B%0A%0A%20var%20prefix%20%3D%20document.getElementById(%22supple-text-bookmarklet-text-prefix-5646%22)%3B%0A%20if%20(prefix%20%26%26%20prefix.value.trim()%20!%3D%20%22%22)%20%7B%0A%20%09prefix.value%20%3D%20prefix.value.trim()%3B%0A%20console.log(%22prefix%3A%20%22%20%2B%20prefix.value)%3B%0A%20result%20%3D%20result%20%2B%20encodeURIComponent(prefix.value)%20%2B%20%22-%2C%22%3B%0A%20%7D%0A%20var%20start%20%3D%20document.getElementById(%22supple-text-bookmarklet-text-start-5646%22)%3B%0A%20if%20(start%20%26%26%20start.value.trim()%20!%3D%20%22%22)%20%7B%0A%20%09start.value%20%3D%20start.value.trim()%3B%0A%20console.log(%22start%3A%20%22%20%2B%20start.value)%3B%0A%20result%20%3D%20result%20%2B%20encodeURIComponent(start.value)%3B%0A%20%7Delse%7B%0A%09%09%20alert(%22Please%20provide%20textStart.%22)%3B%20%09%0A%09%09%20return%20false%3B%0A%20%7D%0A%20var%20end%20%3D%20document.getElementById(%22supple-text-bookmarklet-text-end-5646%22)%3B%0A%20if%20(end%20%26%26%20end.value.trim()%20!%3D%20%22%22)%20%7B%0A%20%09end.value%20%3D%20end.value.trim()%3B%0A%20console.log(%22end%3A%20%22%20%2B%20end.value)%3B%0A%20result%20%3D%20result%20%2B%20%22%2C%22%20%2B%20encodeURIComponent(end.value)%3B%0A%20%7D%0A%20var%20suffix%20%3D%20document.getElementById(%22supple-text-bookmarklet-text-suffix-5646%22)%3B%0A%20if%20(suffix%20%26%26%20suffix.value.trim()%20!%3D%20%22%22)%20%7B%0A%20%09suffix.value%20%3D%20suffix.value.trim()%3B%0A%20console.log(%22suffix%3A%20%22%20%2B%20suffix.value)%3B%0A%20result%20%3D%20result%20%2B%20%22%2C-%22%20%2B%20encodeURIComponent(suffix.value)%3B%0A%20%7D%0A%0A%0A%20if%20(result%20%3D%3D%20%22%23%3A~%3Atext%3D%22)%20%7B%0A%20result%20%2B%3D%20encodeURIComponent(text)%3B%0A%20%7D%20else%20%7B%0A%20var%20link1%20%3D%20link.split('%3F')%5B0%5D%20%2B%20result%3B%0A%20var%20link2%20%3D%20link%20%2B%20result%3B%0A%0A%09%09%09renderResult(resultDiv%2C%20link1%2C%20link2)%3B%0A%0A%0A%09%09%09%09%2F*%0A%20var%20advPanelRes%20%3D%20document.getElementById(%22supple-text-bookmarklet-adv-result-5646%22)%3B%0A%20if%20(advPanelRes)%20%7B%0A%20advPanelRes.style.display%20%3D%20%22block%22%3B%0A%0A%09%09%09%09console.log(%22Will%20call%20renderResult%22)%3B%0A%09%09%09%09renderResult(resultDiv%2C%20link1%2C%20link2)%3B%0A%0A%20if%20(link1%20!%3D%20link2)%20%7B%0A%20var%20link1Div%20%3D%20document.getElementById(%22supple-text-bookmarklet-link-1%22)%3B%0A%20link1Div.innerHTML%20%3D%20%22%3Cstrong%3EClean%20Link%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink1%2B%22'%3E%22%20%2B%20link1%20%2B%20%22%3C%2Fa%3E%22%3B%0A%20link1Div.style.display%20%3D%20%22block%22%3B%0A%0A%20var%20copy1Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-1%22)%3B%0A%20copy1Btn.style.display%20%3D%20%22block%22%3B%0A%20copy1Btn.setAttribute(%22link%22%2C%20link1)%3B%0A%20var%20link2Div%20%3D%20document.getElementById(%22supple-text-bookmarklet-link-2%22)%3B%0A%20var%20copy2Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-2%22)%3B%0A%20copy2Btn.style.display%20%3D%20%22block%22%3B%0A%20link2Div.style.display%20%3D%20%22block%22%3B%0A%20copy2Btn.setAttribute(%22link%22%2C%20link2)%3B%0A%20link2Div.innerHTML%20%3D%20%22%3Cstrong%3EURL%20with%20parameters%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink2%2B%22'%3E%22%20%2B%20link2%20%2B%20%22%3C%2Fa%3E%22%3B%0A%20%7D%20else%20%7B%0A%20var%20link1Div%20%3D%20document.getElementById(%22supple-text-bookmarklet-link-1%22)%3B%0A%20link1Div.innerHTML%20%3D%20%22%3Cstrong%3EClean%20Link%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink1%2B%22'%3E%22%20%2B%20link1%20%2B%20%22%3C%2Fa%3E%22%3B%0A%20link1Div.style.display%20%3D%20%22block%22%3B%0A%20var%20copy1Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-1%22)%3B%0A%20copy1Btn.style.display%20%3D%20%22block%22%3B%0A%20copy1Btn.setAttribute(%22link%22%2C%20link1)%3B%0A%20var%20copy2Btn%20%3D%20document.getElementById(%22supple-text-bookmarklet-btn-2%22)%3B%0A%20copy2Btn.style.display%20%3D%20%22none%22%3B%0A%20%7D%0A%0A%20%7D%0A%20*%2F%0A%20%7D%0A%20console.log(%22advOptionsHandler%3A%20%22%20%2B%20result)%3B%0A%20%7D%0A%0A%20var%20removeBookmarkletPanel%20%3D%20function()%20%7B%0A%20panel%20%3D%20document.getElementById(%22supple-text-bookmarklet-5646%22)%3B%0A%20if%20(panel)%20%7B%0A%20panel.parentNode.removeChild(panel)%3B%0A%20%7D%0A%20%7D%0A%20removeBookmarkletPanel()%3B%0A%20var%20newDiv%20%3D%20document.createElement(%22div%22)%3B%0A%20newDiv.id%20%3D%20'supple-text-bookmarklet-5646'%3B%0A%20var%20heading%20%3D%20document.createElement(%22h4%22)%3B%0A%20heading.innerHTML%20%3D%20%22Scroll%20To%20Text%20Fragment%20Bookmarklet%22%3B%0A%0A%20var%20closePanelBtn%20%3D%20document.createElement(%22span%22)%3B%0A%20closePanelBtn.id%20%3D%20'supple-text-bookmarklet-close-5646'%3B%0A%20closePanelBtn.addEventListener(%22click%22%2C%20removeBookmarkletPanel)%3B%0A%20closePanelBtn.innerHTML%20%3D%20%22X%22%3B%0A%20var%20resultDiv%20%3D%20document.createElement(%22div%22)%3B%0A%20resultDiv.id%20%3D%20'supple-text-bookmarklet-result-5646'%3B%0A%20if%20(resultDiv)%20%7B%0A%20var%20link%20%3D%20window.location.href%3B%0A%20%2F*%0A%20if%20(link.charAt(link.length%20-%201)%20!%3D%20%22%2F%22)%20%7B%0A%20link%20%2B%3D%20'%2F'%3B%0A%20%7D%0A%20*%2F%0A%20var%20link1%20%3D%20link.split('%3F')%5B0%5D%20%2B%20%22%23%3A~%3Atext%3D%22%20%2B%20text%3B%0A%20var%20link2%20%3D%20link%20%2B%20%22%23%3A~%3Atext%3D%22%20%2B%20text%3B%0A%09%09console.log(%22Will%20call%20renderResult%20for%20text%3A%20%5B%22%2Btext%2B%22%5D%22)%3B%0A%0A%20renderResult(resultDiv%2C%20link1%2C%20link2)%3B%0A%20%2F*%0A%20if%20(link1%20!%3D%20link2)%20%7B%0A%20var%20link1Div%20%3D%20document.createElement(%22div%22)%3B%0A%20link1Div.innerHTML%20%3D%20%22%3Cdiv%3E%3Cstrong%3EClean%20Link%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink1%2B%22'%3E%22%20%2B%20link1%20%2B%20%22%3C%2Fa%3E%3C%2Fdiv%3E%22%3B%0A%20copyBtn.setAttribute(%22link%22%2C%20link1)%3B%0A%20link1Div.appendChild(copyBtn)%3B%0A%0A%20var%20link2Div%20%3D%20document.createElement(%22div%22)%3B%0A%20link2Div.innerHTML%20%3D%20%22%3Cdiv%3E%3Cstrong%3EURL%20with%20parameters%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink2%2B%22'%3E%22%20%2B%20link2%20%2B%20%22%3C%2Fa%3E%3C%2Fdiv%3E%22%3B%3B%0A%20var%20copyBtn2%20%3D%20copyBtn.cloneNode(true)%3B%0A%20copyBtn2.setAttribute(%22link%22%2C%20link2)%3B%0A%20copyBtn2.addEventListener(%22click%22%2C%20copyClickEvent)%3B%0A%20link2Div.appendChild(copyBtn2)%3B%0A%20resultDiv.appendChild(link1Div)%3B%0A%20resultDiv.appendChild(link2Div)%3B%0A%20%7D%20else%20%7B%0A%20var%20linkDiv%20%3D%20document.createElement(%22div%22)%3B%0A%20linkDiv.innerHTML%20%3D%20%22%3Cdiv%3E%3Cstrong%3EURL%3A%3C%2Fstrong%3E%20%3Ca%20target%3D'_blank'%20href%3D'%22%2Blink1%2B%22'%3E%22%20%2B%20link1%20%2B%20%22%3C%2Fa%3E%3C%2Fdiv%3E%22%3B%0A%20copyBtn.setAttribute(%22link%22%2C%20link1)%3B%0A%20linkDiv.appendChild(copyBtn)%3B%0A%20resultDiv.appendChild(linkDiv)%3B%0A%20%7D%0A%20resultDiv.style.display%20%3D%20%22block%22%3B%0A%20*%2F%0A%20%7D%0A%0A%20var%20moreOptions%20%3D%20document.createElement(%22button%22)%3B%0A%20moreOptions.innerHTML%20%3D%20%22More%20Options%20%26%238659%3B%22%3B%0A%20moreOptions.setAttribute(%22class%22%2C%20'moreOptions')%3B%0A%20moreOptions.addEventListener(%22click%22%2C%20moreOptionsHandler)%3B%0A%0A%0A%20var%20advSettDiv%20%3D%20document.createElement(%22div%22)%3B%0A%20advSettDiv.id%20%3D%20'supple-text-bookmarklet-adv-5646'%3B%0A%20advSettDiv.style.display%20%3D%20%22none%22%3B%0A%20advSettDiv.innerHTML%20%3D%20%22%3Cdiv%20class%3D'supple-text-bookmarklet-adv-container'%3E%3Cdiv%20class%3D'supple-text-bookmarklet-label'%3EtextStart%20(required)%3A%20%3C%2Fdiv%3E%20%3Cdiv%20class%3D'supple-text-bookmarklet-input'%3E%3Cinput%20id%3D'supple-text-bookmarklet-text-start-5646'%20value%3D'%22%2BdecodeURIComponent(text)%2B%22'%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%22%3B%0A%20advSettDiv.innerHTML%20%2B%3D%20%22%3Cdiv%20class%3D'supple-text-bookmarklet-adv-container'%3E%3Cdiv%20class%3D'supple-text-bookmarklet-label'%3EtextEnd%20(optional)%3A%3C%2Fdiv%3E%20%3Cdiv%20class%3D'supple-text-bookmarklet-input'%3E%3Cinput%20id%3D'supple-text-bookmarklet-text-end-5646'%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%22%3B%0A%20advSettDiv.innerHTML%20%2B%3D%20%22%3Cdiv%20class%3D'supple-text-bookmarklet-adv-container'%3E%3Cdiv%20class%3D'supple-text-bookmarklet-label'%3Eprefix-%20(optional)%3A%3C%2Fdiv%3E%20%3Cdiv%20class%3D'supple-text-bookmarklet-input'%3E%3Cinput%20id%3D'supple-text-bookmarklet-text-prefix-5646'%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%22%3B%0A%20advSettDiv.innerHTML%20%2B%3D%20%22%3Cdiv%20class%3D'supple-text-bookmarklet-adv-container'%3E%3Cdiv%20class%3D'supple-text-bookmarklet-label'%3E-suffix%20(optional)%3A%3C%2Fdiv%3E%20%3Cdiv%20class%3D'supple-text-bookmarklet-input'%3E%3Cinput%20id%3D'supple-text-bookmarklet-text-suffix-5646'%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%22%3B%0A%0A%0A%20var%20advSettResDiv%20%3D%20document.createElement(%22div%22)%3B%0A%20advSettResDiv.id%20%3D%20'supple-text-bookmarklet-adv-result-5646'%3B%0A%20advSettResDiv.style.display%20%3D%20%22none%22%3B%0A%0A%20%2F*%0A%20var%20link1Div%20%3D%20document.createElement(%22div%22)%3B%0A%20link1Div.id%20%3D%20'supple-text-bookmarklet-link-1'%3B%0A%20link1Div.style.display%20%3D%20%22none%22%3B%0A%0A%20var%20link2Div%20%3D%20document.createElement(%22div%22)%3B%0A%20link2Div.id%20%3D%20'supple-text-bookmarklet-link-2'%3B%0A%20link2Div.style.display%20%3D%20%22none%22%3B%0A%20*%2F%0A%0A%0A%20var%20genBtn%20%3D%20document.createElement(%22button%22)%3B%0A%20genBtn.innerHTML%20%3D%20%22Generate%20Links%22%3B%0A%20genBtn.addEventListener(%22click%22%2C%20advOptionsHandler)%3B%0A%20advSettDiv.appendChild(genBtn)%3B%0A%20advSettDiv.appendChild(advSettResDiv)%3B%0A%0A%20%2F*%0A%20var%20copyBtn1%20%3D%20copyBtn.cloneNode(true)%3B%0A%20copyBtn1.id%20%3D%20'supple-text-bookmarklet-btn-1'%3B%0A%20copyBtn1.onclick%20%3D%20copyClickEvent%3B%0A%20var%20copyBtn2%20%3D%20copyBtn.cloneNode(true)%3B%0A%20copyBtn2.id%20%3D%20'supple-text-bookmarklet-btn-2'%3B%0A%20copyBtn2.onclick%20%3D%20copyClickEvent%3B%0A%20advSettResDiv.appendChild(link1Div)%3B%0A%20advSettResDiv.appendChild(copyBtn1)%3B%0A%20advSettResDiv.appendChild(link2Div)%3B%0A%20advSettResDiv.appendChild(copyBtn2)%3B%0A%20*%2F%0A%20var%20creditDiv%20%3D%20document.createElement(%22div%22)%3B%0A%20creditDiv.id%20%3D%20'supple-text-bookmarklet-credit-5646'%3B%0A%20creditDiv.innerHTML%20%3D%20'Bookmarklet%20'%2B%20bookmarklet_version%20%2B'%20by%20%3Ca%20rel%3D%22nofollow%22%20target%3D%22_blank%22%20href%3D%22https%3A%2F%2Fsupple.com.au%2F%22%3E%3Cimg%20width%3D%2263%22%20height%3D%2228%22%20src%3D%22https%3A%2F%2Fsupple.com.au%2Fwp-content%2Fthemes%2Fsupple%2Fimages%2Flogo.png%22%20title%3D%22Supple%22%3E%3C%2Fa%3E%26nbsp%3B%3Ca%20rel%3D%22nofollow%22%20href%3D%22https%3A%2F%2Fsupple.com.au%2Ftools%2Fscroll-to-text-fragment-generator-bookmarklet%2F%22%20target%3D%22_blank%22%20class%3D%22moreinfo%22%3EMore%20Info%20%26%20Tutorial%3C%2Fa%3E'%3B%0A%20newDiv.appendChild(heading)%3B%0A%20newDiv.appendChild(closePanelBtn)%3B%0A%20newDiv.appendChild(resultDiv)%3B%0A%20newDiv.appendChild(moreOptions)%3B%0A%20newDiv.appendChild(advSettDiv)%3B%0A%20newDiv.appendChild(creditDiv)%3B%0A%20document.body.appendChild(newDiv)%3B%0A%20document.body.insertBefore(style%2C%20newDiv)%3B%0A%20%0A%20console.log(%22Result%3A%20%5B%22%20%2B%20text%20%2B%20%22%5D%22)%3B%0A%7D%7D)()%3B
从https://supple.com.au/tools/scroll-to-text-fragment-generator-bookmarklet/#:~:text=watch%20the%20video.-,Scroll%20To%20Text%20Fragment:
(
想知道一些很酷的东西吗?Chrome 已经附带了片段寻址超越文本片段 –使用一些简单的°CSS 选择器 类型。但您必须在
chrome://flags/#enable-css-selector-fragment-anchor
目前似乎还没有工具可以协助生成片段链接。
一个可行的例子:https://github.com/WICG/scroll-to-text-fragment/blob/main/EXTENSIONS.md#:~:selector(type=CssSelector,value=img[src$="6fc30.png"])
它甚至支持:has()
。(通常应用 CSS 规则是支持的目前只有 Safari 浏览器支持此功能。但您可以使用 µBlock(或其他工具)来注入°° 使用 CSS:has()
。
° 出于安全原因
°°(或替代语法)
)
答案3
harrymc 提供的标志不再存在。
但是一个新的插件已经取代了它:chrome://flags/#shared-highlighting-refined-blocklist
启用后,我就能够在 Reddit 中使用该功能(至少目前如此)。