Can I create a Chrome Extension that save images to specific names? - javascript

I like to save images to my hard-drive to create mood-board for art projects. I usually use Date.now() in chrome's console to create a string of number and copy the number as my file name - so the saved images are in the an order - it is easier for me to look them up later.
I thought, it would be convenient if I create an extension to help me to accomplish this.
So I want to create a new option in the context menu and call it "Download This Image" and when I click it, it will automatically generate a string of number and use them as the default file name. Unfortunately, it doesn't quite work out.
The reason I want to create a new option is that, most of the time, I don't want to change the filename of the images I download. I only want to change them when I want to save them to my inspirational folder.

Okay. I solved this. Here is the extension's source code if anyone is interested.
https://github.com/aeroxy/save_image

Related

How to automatically make array of all files in website folder?

Let's say I have a folder of about 100 images on my website called "IMG"
Now let's say I have a div element: <div id="templateDiv"></div>
Using javascript, how would I add all images from "IMG/" into that div without adding <img src="IMG/IMGNAME.jpg"> for every image?
Sorry, I'm not very good at explaining.
Just ignore the fact that would take ages to load.
EDIT
Ok my bad explanation skills have made me change my question.
How do I automatically make array of all files in website directory?
Okay, your question is incredibly unclear, but from reading all your other comments and things, it seems you simply want to get an array that contains the filename of every file in a directory? If that's what you want, then it won't be possible (I don't believe) since only the server knows which files are where, and you can't request the contents of a directory from a server using JavaScript.
However if you were using Node.js on a local directory, then it could be done. But I don't believe that's your case.
That being said, you have three alternative options:
Name every image file 1.png, 2.png, 3.png, etc. Then use a for loop and get each one using (i + 1) + ".png"
If you can't rename the files, but the files are named via user input, you could collect the user's input at the time of file creation and add the name of the newly created file into another file/an array/localStorage so that it could be retrieved later.
If you can't rename the files, but the filenames are also never known to the program that needs them, then you could create an array of all the filenames (manually) and iterate over that to find all the files that you want.
Please, somebody let me know if I'm wrong and if there actually is a way to make a request to a server that tells the client all the files in a directory. That seems incredibly unlikely though.
Another potential solution just came to mind. You could write a PHP script (or Node.js or any server-side language, really) that scans a directory, creates a list of all the filenames there, and then sends that back over HTTP. Then you could simply make an XMLHttpRequest to that PHP file and have it do the work. How does that sound?

Is there any way to see an uploaded document into my react app?

Hi onto my react app I need to see a document but I cannot upload it manually. I'll explain, the user if need, could upload a document and into another part of the app could see it.
I want to know if there's a possibility to organize something like
See document
So the user onClick can see the doc opened in another tab. I do some logic but I upload the document on my store after he can see it in the review mode.
So can I visualize it without charging it on localStorage or sessionStorage, should I use an external library?
It depends on the format of the document. if it's an image you can show it by encoding it to base64 for other types of documents I'm afraid you have to have it stored at some URL.
You don't need to upload it anywhere to open it, after the 'upload' (using the file chooser) you can store it in a variable and use it as you please (keep in mind that this is not always a good approach). However if you want to visualize\open it in the application, it depends on the file format and you might need to use an external library to interpret and present it
edit: add note in parenthesis

Javascript to prompt for pdf files to insert?

I am attempting to have a button on a form that will launch file explorer for the user to select pdf files to insert into form.
The insertPages script will insert pages from a specific cPath, but I need the user to be able to select the pages to insert, as they will be different from case to case. Is there a way to accomplish this using javascript?
I am using Bluebeam, which is very similar to Acrobat. I have created several templates and javascript code using the Acrobat API Reference, and thus far the Bluebeam engine appears to operate nearly identically. In a perfect world, the button would launch the "Insert Pages" menu in Bluebeam.
Thanks in advance for the help!!
If this were Acrobat, I'd use app.browseForDoc(). The returned object has three properties...
cFS - A string containing the resulting file system name for the chosen file.
cPath - A string containing the resulting path for the chosen file.
cURL - A string containing the resulting URL for the chosen file.
Get the full path to the file from there then use insertPages.
In Acrobat, it can only be run in a Privileged context. I'm not sure if it will work the same way in BlueBeam though they have done a fairly good job of duplicating the form field related JavaScripts.

Webpage: Button to check self (HTML page) and open the next HTML page alphabetically located in the same folder

Curious if by using javascript or the like, I can click a button and it would open the next alphabetically listed .htm page I have located in that same folder. I would try to use a naming convention, but the .htm files change quite frequently and their names can be random. The good news is there are not many files even at their greatest amount.
After doing some more research to help show that I was attempting to solve this too, I found that this sort of local perspective scripting isn't safe and have therefore sought alternative remedies elsewhere. Thanks.
(It is help full asp.net user like me.Its may be help full for.)
I have an idia for you from which you can solved your problem.
The all file's name store in list or dictionary as like you and also take "static" variables name like "FileName" that is use for file name and another like "CurrentIndex".But both variable are declared globally.When we click on button then increase current index and also manage the file name according to current index.
If till now your problem is not solved out, please response me

HTML5 FS API: Let the user create files outside of the sandbox?

Is there a way to create a file outside of the sandbox? Maybe something that works by first storing the file inside the sandbox and then letting the user drag a link to the locally stored file into a regular folder?
It is for a webchat: I want the user to be able to receive files, but I can't figure out a way that ensures that he can choose the target location that doesn't need a right-click->save as. If there is a better solution than using the filesystem API, feel free to suggest that, too.
How about an "a" element with a download attribute, and using FileEntry.toURL() to populate the href target?
Use a signed java applet to get root access to the system

Categories