qufighter / localfilebrowser Goto Github PK
View Code? Open in Web Editor NEWThis Google Chrome extension enhances local directory browsing by adding next and preview buttons to images allowing one to navigate to other images in the directory.
This Google Chrome extension enhances local directory browsing by adding next and preview buttons to images allowing one to navigate to other images in the directory.
While looking for a way to easily preview local images I found your extension. Although it doesn't do what I want, I reviewed the code and have some suggestions.
file:///
access in order to be functional, and you're getting 1-star reviews because people can't be bothered to read your description that explicitly lists this requirement. I suggest to use chrome.extension.isAllowedFileSchemeAccess
to check whether the extension has file access, and if not prompt the user for permission (e.g. by opening a new tab).webNavigation
permission (you already have the tabs
permission, so there is no permission warning) and use the chrome.webNavigation.onBeforeNavigate
event to detect navigations to file://
-URLs, and show the permission request when the extension lacks the file permission.Here is an example (for local PDF files): https://github.com/mozilla/pdf.js/blob/64a409b539bf7974aa695dec82fa414cfcb777ac/extensions/chromium/pdfHandler.js#L191-L215
Note that the above example replaces the tab with an extension page because the extension assumes that Chrome is not able to open the PDF file without the extension. In your case, you probably want to open a new tab instead (chrome.tabs.create
).
It seems that you're fighting against the same origin policy in localfiles.user.js
and background.js
to rotate pictures. The current "solution" is to repeatedly move the image around, capture a screenshot of the tab and assemble the images later. This is fragile, I tested it on one image and it did not work.
I suggest to use XMLHttpRequest
with responseType='blob'
(from the content script, localfiles.user.js
), then get a same-origin URL using URL.createObjectURL(blob)
, and then directly load this image in an new Image()
for straightforward manipulation on a canvas.
This would be much faster than your current method and also less error-prone.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.