ichaoX / ext-textFragment

Firefox Text Fragment Extension
https://addons.mozilla.org/en-US/firefox/addon/text-fragment/
GNU General Public License v3.0
4 stars 0 forks source link

Allow operating on restricted pages. #5

Open RokeJulianLockhart opened 1 month ago

RokeJulianLockhart commented 1 month ago

https://github.com/gildas-lormeau/SingleFile/issues/1494#issue-2395597545

This might explain why this doesn't appear to work in PDFs.

ichaoX commented 1 month ago

This extension does not actively limit functionality on specific pages. If necessary permissions are lacking for a particular page, related features will be unavailable.

Highlighting should have basic support, like: pdf.

However, copying doesn't work due to tabs.executeScript(), and I'm unsure if there are other solutions.

If permission issues can be resolved, the effect should still be acceptable (unless PDF loading exceeds 5 seconds, the extension will abandon the search), like: pdf.js.

Currently, a possible solution would be to embed a PDF viewer within this extension, but I believe this feature exceeds the scope of this extension.

RokeJulianLockhart commented 1 month ago

https://github.com/ichaoX/ext-textFragment/issues/5#issuecomment-2217746215

@ichaoX, https://mozilla.github.io/pdf.js/legacy/web/compressed.tracemonkey-pldi-09.pdf#:~:text=dynamic%20compiler%20for-,JavaScript,-based%20on%20our doesn't work for me. Should the extension automatically highlight the selected text after the PDF is downloaded?

  1. Screenshot_20240709_143242

  2. https://github.com/ichaoX/ext-textFragment/issues/5#issuecomment-2218116930

A PDF viewer would indeed set a somewhat untennable precedent, considering how many formats Firefox and Chrome support which can contain text.

ichaoX commented 1 month ago

Should the extension automatically highlight the selected text after the PDF is downloaded?

My setting is to open PDFs using the browser's built-in PDF viewer by default, while this extension uses the Find API for highlighting.

This avoids the need to download the file first and then open it in the browser, which would otherwise lose the URL's #:~:text=.

RokeJulianLockhart commented 1 month ago

https://github.com/ichaoX/ext-textFragment/issues/5#issuecomment-2217854576

@ichaoX, could you show a screencast of how you do it? By the way, I uploaded the wrong one there - that must have seemed incoherent. I've fixed it:

https://github.com/ichaoX/ext-textFragment/assets/42837531/65380757-a404-444b-985c-0d0f9421067e

ichaoX commented 1 month ago

image

Alternatively, you can try appending #:~:text=* to the file:///*.pdf.

RokeJulianLockhart commented 2 weeks ago

https://github.com/ichaoX/ext-textFragment/issues/5#issuecomment-2218160430

@ichaoX, how do you generate that fragment without the extension functioning, though? Is it enough to copy some of the file content and put it through https://meyerweb.com/eric/tools/dencoder/ and append it to #:~:text=?

ichaoX commented 2 weeks ago

@ichaoX, how do you generate that fragment without the extension functioning, though? Is it enough to copy some of the file content and put it through https://meyerweb.com/eric/tools/dencoder/ and append it to #:~:text=?

There is currently no simple way to achieve this.

I'm unsure if there are other ways to write to the clipboard. Even if copying is done through additional steps, due to the lack of get context capabilities, features such as creating links and finding text fragments remain degraded.