9

Steps to reproduce:

  1. Navigate Google Chrome to https://www.reddit.com/r/RetroArch/comments/7m8wlo/issues_with_nvidia_shield_controller_shield_tv/
  2. Use CTRL+f to search forward for "Try uninstalling Retroarch".
  3. Select that same text, click right mouse button, and try to select Copy link to highlight. Notice it is greyed out (meaning deactivated); see below screenshot.

enter image description here

Compare this to other sites such as SuperUser whereby this feature works: 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

I've tried many other Reddit pages and they all managed to cause Chrome to deactivate the Copy link to highlight feature.

I speculate that somehow the website itself can cause Chrome to deactivate that menu entry; is that the case here? If so, how do they manage to do that?

My version of the browser running on Microsoft Windows 10: Version 96.0.4664.93 (Official Build) (64-bit)

This defect also reproduces on Google Chrome running on Ubuntu Linux 20.04.

bgoodr
  • 641
  • By now the feature works for me  on your reddit example fragment. But not on this example: http://web.archive.org/web/20171213212419/http://vim.1045645.n5.nabble.com/dump-register-to-file-without-open-td1170411.html#:%7E:text=simpler – Aaron Thoma Mar 06 '22 at 19:02
  • 1
    Nobody is answering the question. They're trying to explain how to workaround it. The question is: Why is the menu item disabled? For example https://fintrac-canafe.canada.ca/guidance-directives/documents-prog/str/str-dod-api-eng Why is it ever disabled? Why would someone decide that i cannot create a link to some text inside an e-mail message inside my Gmail? Why is it ever disabled at all? Why do we need a Google Extension by Google to enable the functionality? Put it another way, Why does Google Chrome's "Copy link to highlight" feature not work on Reddit sites? – Ian Boyd Jan 02 '24 at 15:54

3 Answers3

7

Go to chrome://flags/#shared-highlighting-use-blocklist and set it to Disabled. This will fix the problem, as long as the Chrome developers do not decide to remove this option.

This setting is described as:

Uses a blocklist to disable Shared Highlighting link generation on certain sites where personalized or dynamic content or other technical restrictions make it unlikely that a URL can be generated and actually work when shared. – Mac, Windows, Linux, Chrome OS, Android

EDIT:

chrome://flags/#shared-highlighting-use-blocklist was lately deprecated, but perhaps was changed to chrome://flags/#shared-highlighting-refined-blocklist defined as:

Narrow the Blocklist for enabling Shared Highlighting. – Mac, Windows, Linux, ChromeOS, Android, Fuchsia, Lacros

harrymc
  • 480,290
  • 3
    … aaand it’s gone – they did indeed decide to remove the option flag, as they always do … – Aaron Thoma Mar 06 '22 at 18:58
  • I've accepted this answer, but later on N R's answer revealed that chrome://flags/#shared-highlighting-use-blocklist was indeed "removed" (or so it seems), but perhaps was changed to chrome://flags/#shared-highlighting-refined-blocklist. Could harrymc update this answer accordingly? ... – bgoodr Aug 25 '22 at 14:06
  • ... Also, I've verified that N R's answer is correct: My original post acts as a test case that I reused to prove that the Copy link to highlight context menu entry on that reddit page was disabled before I enabled the chrome://flags/#shared-highlighting-refined-blocklist flag. – bgoodr Aug 25 '22 at 14:06
  • Fine, I have added this to my answer. – harrymc Aug 25 '22 at 14:15
  • The #shared-highlighting-... options appear to have been removed from Chrome 121 btw. – Dai Feb 09 '24 at 05:36
5

Google’s Link to Text Fragment extension works more generally. Example: enter image description here generates 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 which works.
(( Its automatic fragment generation is a bit more verbose than necessary: The highlighted word simpler is unique on the page, so the fragment link also works fine without the open/put is context: http://web.archive.org/web/20171213212419/http://vim.1045645.n5.nabble.com/dump-register-to-file-without-open-td1170411.html#:~:text=simpler ))


(Unfortunately, Google doesn’t let you remove the original Copy link to highlight context menu entry anymore. [reference] So adding the extension means a bit more clutter.)

Also unfortunately, according to my googling, the more advanced functionality of  automatically adding context (prefix-,-postfix) when required for unique identification  does not seem to be available in a bookmarklet. If you don’t need that functionality, you can use for example this bookmarklet:

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

from https://supple.com.au/tools/scroll-to-text-fragment-generator-bookmarklet/#:~:text=watch%20the%20video.-,Scroll%20To%20Text%20Fragment : enter image description here


(
Wanna know something cool? Chrome already ships with a working functionality for fragment addressing beyond text snippets – using some simple° CSS selector types. But you have to enable it manually at

chrome://flags/#enable-css-selector-fragment-anchor

And no tools seem to exist yet  for assisting in generating the fragment links.
A working example: https://github.com/WICG/scroll-to-text-fragment/blob/main/EXTENSIONS.md#:~:selector(type=CssSelector,value=img[src$="6fc30.png"])

It even supports :has(). (Which for normally applying CSS rules  is supported by Safari as the only browser so far. But you can use µBlock (or probably other tools) to inject°° CSS that uses :has().)

° for security reasons
°° (or alternative syntax)
)

  • This is very useful information. However, I'm choosing not to use it, at least for now, because your answer advocates installing one or more extensions. Under that scenario, I would have to pay an additional time-cost to cross-train with everyone that will want to resolve any "share links" I create. Paying that cost would be reasonable, actually, except I cannot predict who is going to click on those share links in the future. Yes, you could counter-argue that not all browsers and/or their multitude of versions cannot process them, and that is true, but I'm trying to be a minimalist. – bgoodr Aug 25 '22 at 14:10
1

The flag that harrymc provided is no longer there.

But a new one has taken its place: chrome://flags/#shared-highlighting-refined-blocklist

After enabling it I was able to use the feature in Reddit (at least for now).

N R
  • 111