GoogleChromeLabs / link-to-text-fragment

Browser extension that allows for linking to arbitrary text fragments.
https://chrome.google.com/webstore/detail/link-to-text-fragment/pbcodcjpfjdpcineamnnmbkkmkdpajjg
Apache License 2.0
412 stars 33 forks source link

Does not work on Firefox anymore #95

Closed Qhilm closed 1 month ago

Qhilm commented 1 year ago

Currently, the only way to get it to work on Firefox is:

  1. load the link to text fragment
  2. it fails
  3. click on the "link to text fragment" add-on icon
  4. Error is displayed "INVALID_SELECTION: The selection provided could not be used."
  5. reload web page in Firefox
  6. it works, text fragment is highlighted.

These steps must be repeated for every link, hence it's not very usable anymore.

Example link: https://blog.chromium.org/2019/12/chrome-80-content-indexing-es-modules.html#:~:text=ECMAScript%20Modules%20in%20Web%20Workers

Firefox 117.0.1 macOS 13.5.2

tomayac commented 1 year ago

I'm not sure what changed on the Firefox side. It was working just fine, but I can confirm that it stopped working on Firefox 117 now. It uses manifest v3, so maybe there's some problem there? You can see the recent commits if you want to investigate.

There's a known issue on Chrome (and probably Firefox), where extension contexts can't use the Async Clipboard API because it's not focused. In Chrome, this is tracked as https://crbug.com/1404835.

RokeJulianLockhart commented 1 year ago

https://github.com/GoogleChromeLabs/link-to-text-fragment/issues/95#issue-1895851565

@Qhilm, it has worked for me using https://download.opensuse.org/repositories/openSUSE:/Factory/standard/x86_64/MozillaFirefox-122.0-3.2.x86_64.rpm on cpe:/o:opensuse:tumbleweed from :20230915 to :20240131.

  1. https://github.com/GoogleChromeLabs/link-to-text-fragment/assets/42837531/a790f05a-b275-47cc-88ce-e8eec0f5a8f7

  2. Screenshot_20230919_185952

johnmaguire commented 1 year ago

Firefox 119 on macOS Sonoma. I no longer see the "Copy link to selected text" context menu item.

Qhilm commented 1 year ago

Firefox 119 on macOS Sonoma. I no longer see the "Copy link to selected text" context menu item.

you may have to click on the add-on icon once.

budak7273 commented 10 months ago

Seems to be working without any additional steps for me on Windows firefox 121.0.1 (64-bit)

krystian3w commented 3 months ago

Should works without add-ons with Firefox Nightly 131 (Seems chance run at 1 October for stable release and at 24 June 2025 for ESR 140+).

Pfeil commented 1 month ago

MacOS Sonoma 14.7 Firefox 131.0.3

I wonder if the issue was the fact that I was already on a page loaded via a text fragment link. But if so, why would reinstalling the extension not help at all?...

Unfortunately, I can't tell which version of the extension I had before reinstalling. After the first step, I also visited the about:addons page, which may have triggered a silent update? Any way to get/provide some logging or so from the user side here from the extension?

tomayac commented 1 month ago

@dotproto Could the above https://github.com/GoogleChromeLabs/link-to-text-fragment/issues/95#issuecomment-2422326148 be related to the trick you mentioned in https://github.com/GoogleChromeLabs/link-to-text-fragment/issues/108#issuecomment-2414185289? Is it a full replacement of the service worker?

I also need an offscreen document for the clipboard: https://github.com/GoogleChromeLabs/link-to-text-fragment/blob/84c592c3754ff3259cc4e473865dbd8a8def2396/service_worker.js#L24

QMiqTx6DHn1bA9yaNaAbsD3CLG8gTmd4 commented 1 month ago

@tomayac

New (yesterday's, v2.5.0) release broke it for me on Firefox.

When using "Copy Link to Selected Text" the following error appears in Browser Console and no link is present in clipboard ☹️

Uncaught (in promise) ReferenceError: clients is not defined
    setupOffscreenDocument moz-extension://7eab01c8-a082-47c5-8325-33b93f3f9759/service_worker.js:29
    onCopy moz-extension://7eab01c8-a082-47c5-8325-33b93f3f9759/service_worker.js:167
    <anonymous> moz-extension://7eab01c8-a082-47c5-8325-33b93f3f9759/service_worker.js:126
[service_worker.js:29:26](moz-extension://7eab01c8-a082-47c5-8325-33b93f3f9759/service_worker.js)

Rolling back to v2.3.2 makes the extension work again.

Running on Firefox 131.0.3.

tomayac commented 1 month ago

Alright, rolled back to v2.3.2. @dotproto, the trick from https://github.com/GoogleChromeLabs/link-to-text-fragment/issues/108#issuecomment-2414185289 unfortunately doesn't seem like a drop-in replacement after all. The validation when uploading the new version could have caught this: https://github.com/GoogleChromeLabs/link-to-text-fragment/blob/84c592c3754ff3259cc4e473865dbd8a8def2396/service_worker.js#L29

Pfeil commented 1 month ago

I successfully copied a link yesterday, same machine. Didn't look at the version, I just gave it a shot and was happy it worked. So I assume the rollback did the trick for now. Thanks!

tomayac commented 1 month ago

Thanks for confirming! We're in a funny world right now where Firefox continues manifest v2 support and has partial manifest v3 support, and where Chrome phases out manifest v2 support and forces a manifest v3 migration, which it fully supports, but which lacks rich clipboard support in service worker offscreen documents (https://crbug.com/1404835). This is not a problem on Firefox, though, as we can remain on the manifest v2 version, so closing this Issue.