Code Monkey home page Code Monkey logo

Comments (7)

Adr0it avatar Adr0it commented on May 29, 2024 1

Works amazingly, nice. I don't have a clue how to navigate git to get dev branch updates, so I just kept sticking files together until it compiled the Chrome extension, and it worked at last.

image

from doqment.

shivaprsd avatar shivaprsd commented on May 29, 2024

@Adr0it Thanks for stopping by! Can you explain how automatically opening offline PDFs would help your bookmarking extension? I am not able to see any connection there. 😕

Can you also show me how you are injecting your content script? My main concerns here are permissions and consistency. We would need wide host permissions to run content scripts in all file:// urls, and auto-opening only offline PDFs creates different behaviours for offline v/s online.

In Firefox doqment auto-opens all URLs. This is because there the intent is to replace the default viewer (as doqment is only a modified version of it). In Chrome the design is different both due to technical limitations of MV3 and for letting users use doqment as a second PDF viewer without invading their privacy.

from doqment.

Adr0it avatar Adr0it commented on May 29, 2024

The feature of automatically opening offline PDFs is just convenient in my opinion. It doesn't have anything to do with my extension.

Here is what I did. Just put pdf file in manifest (you can also add https:///.pdf for online sources) for when the content script runs. The content script then sends really any random message to the service worker, and the service worker simply opens the viewer and closes current tab (which has default pdf viewer). Not really the best solution, but it's convenient.
image
image
image

from doqment.

shivaprsd avatar shivaprsd commented on May 29, 2024

Thanks, I got your intent now. I guess this could be done a bit more neatly with Declarative Net Requests redirect rule, or even chrome.tabs.update() instead of opening a new tab.

The problem with this is that we are relying on the .pdf extension to detect PDFs, which may not always be the case. This is why currently we check document.contentType (Chrome) or MIME type in response headers (Firefox). This is something that neither match patterns nor DNR rules can currently handle.

Even if we find a way, this will inevitably need a permission escalation, that can result in the extension being temporarily blocked on the Chrome Web Store, pending a manual review. Yet I understand the desire for convenience, so let me edit the title to better reflect the general case. This has to be implemented thoughtfully.

from doqment.

shivaprsd avatar shivaprsd commented on May 29, 2024

I figured out a way to do this with dynamic content scripts so that the permissions can remain optional. Now on dev branch: 85f740e.

@Adr0it It is loosely based on your idea, so thank you! Can you please try it out and get back? Just right click on the extension action and switch it on via the menus (first the "Always allow..." menu followed by the other).

from doqment.

shivaprsd avatar shivaprsd commented on May 29, 2024

@Adr0it Thanks! Can you give your feedback on the interface, i.e. having to go through two menus to enable it? I did it that way to make the code cleaner, and enabling it requires enabling the first menu anyway. Did you find it cumbersome? Would you find it confusing if I had not told you exactly what to do?

P.S.
For your future reference, you can check out the dev branch like this in git:

$ git clone https://github.com/shivaprsd/doqment.git
$ cd doqment
$ git checkout dev

Or, if you don't use command line, you can first select dev in branches on the GitHub website interface and go to <> Code ➡️
Download Zip to get the dev branch files.

from doqment.

shivaprsd avatar shivaprsd commented on May 29, 2024

Fixed in v0.6.

from doqment.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.