Fetch URL from Chrome tab and inserting result into user form - javascript

I am new to stackoverflow and generally new at chrome extensions and Javascript, so bear with me! I am creating an extension that consists of a popup window that displays a form where notes can be taken concerning a specific set of web pages. When the form submits (or maybe on load), I would like my extension to extract the URL from the active tab and send it along with all other form data as a reference in the database. Is this possible? I was hoping that the web URL would automatically populate a specific non-editable text box upon launching the popup. Just not sure where to start...Ideas?
I have a popup.html which contains the form and it already submits correctly to a MySQL database. I also use the popup.js file in the extension.
From what I have read, I need to include a "chrome.tabs.query()" function into my code, but I am unsure of how to write the function in javascript and how to interface the variable with the form.
Thanks in advance!

Related

Saving changed PDF with form fields from embedded chrome viewer and uploading to server

We are using the default embedded chrome pdf viewer to display a pdf with form fields. User can easily fill out the form. When done we have to click the download button that allows them to download the form with or without changes.
What we would like to achieve is to have a save button in this component that would fetch the pdf with changes and upload it to the server.
We don't mind adding a library for it, currently finding it hard to find documentation and accessing anything in this embedded pdf viewer.
One thing you could do, is to add a Submit button, which does submit the data (or the form as document, under some circumstances) back to your server. In the latter case, you then could push back the filled form; in the former, you could use an utility to fill the blank form with the data and push that result.
This works as long as the form is not too intelligent (although Chromium has a relatively good PDF viewing component, which understands a bit of Acrobat JavaScript). Otherwise, you better recommend to download the blank form and have it filled out in a good PDF viewer (industry standard for macOS and Windows is Adobe Acrobat Reader). If you need to gather data in this situation, the submit function would be your choice.

Is it possible to set autofill form data via chrome extension?

I am looking to build a chrome extension wherein I the extension can set the chrome autofill for a person (i.e. save addresses and other information like basic form data). I can then go to a few websites, fill a few forms.
The extension can then set the data for another person and the cycle repeats.
Since the forms can contain dynamic fields, I want this data set in the autofill so chrome can take care of most of the part and I can rectify any problems before submitting the form.
I haven't found a direct chrome extension API to do this. Is this possible to be done?
Thanks in advance.
UPDATE: I went through this: Import autofill data from a file into Chrome but is there any way to do it through the extension?

How to edit and update the pdf file?

I am working on a web application using asp.net.
One of requirements demands that I open a given pdf file containing form fields, fill the fields like checking the check boxes, selecting the values from the select inputs and entering the text in text boxes etc.
Once the fields are set then I need to submit it to server and save this as a new pdf file or update the same pdf file.
I don't have a submit button in the pdf itself. I need to submit the details to server using a button outside the pdf file.
When you have a file on a server and you serve it to a client, there are two instances of the file: one on the server and one on the client.
The end user can fill out the form on the client, but will need a button on the PDF if you want him to submit the data he entered to the server. This is explained here: Edit pdf embedded in the browser and save the pdf directly to server
Your requirement to have a button outside the PDF is in most cases impossible: it requires establishing communication between the PDF viewer and the browser. This is only possible in a very specific environment: it requires the Adobe Reader plug-in and it won't ever work on Mac. See also PDF hostContainer callback
You need to reconsider the requirement of having a button outside the PDF! I've been working on a similar project where the submit button was added to the form on-the-fly. The button was only visible on the PDF on the client. The client used that button to submit the data.
Once the data is submitted (see Edit pdf embedded in the browser and save the pdf directly to server to find out in which form the data can be transmitted), you can fill out the form on the server-side. This is explained here:
How to fill out a pdf file programatically?
Saving .xfdf as .pdf
... (this is a very common question; a simple search will reveal more answers)
The form on your server is your template. I assume that this template will be served to many different people. If that is true, then you do not want to replace that template with a form that is filled out by the previous user! (This code cause some serious privacy issues.)
If you really want to update the PDF that exists on the server (instead of creating a new copy), you might also want to read the answer to this question: How to update a PDF without creating a new PDF?

How can I prevent saving/downloading web page?

I was wondering if there was a way to prevent a user from saving/downloading a web page? Specifically, I mean not letting them have access to the data displayed through my web application on their own machine?
I've heard that this is not possible since the browser must have access to the source code/data, but at the same time, I've noticed that if I to my gmail account, open an email, save the page, but when I try to open that page on my computer, it doesn't work. Furthermore, if I click "view source", I can see that even the source does not display the entire email message, even though the email is opened in my browser.
How it's possible for gmail to prevent me from seeing that email data?
Thats what called rendering pages using dynamic data without refreshing page (AJAX). The entire page source code is not downloaded in one go and components within the page request data asynchronously to display content. Try googling it and you will find more information.
In View source you can only see the HTML, CSS, JavaScript codes. No one can copy any dynamic code (PHP) from view source.
You can't stop anyone to see your html,css code in browser, as we are having view source option.
Maximum what you can do is disable right click on your page. Thant can be done through JavaScript.

Javascript crossdomain widget

I want to create javascript widget similar to linkedin Member profile. https://developer.linkedin.com/plugins/member-profile-plugin?button-type-inline=true
On my site the user can manage some data.
I want to allow for user to copy some HTML code and insert in his site HTML to display the data.
I want HTML code looks like:
<script src="http://mysite.com/code.js?userid=123"></script>
And if user inserts this code in his site then javascript code is loaded and data are displayed (widget displayed)
How to do this? I know about crossdomain restrictions. But in case of linkedin this is not the problem. Their widget works fine.
Thanks.
UPDATE.
As i understand from comments, it is not the problem to display any data in page that includes my javascript file. I am going to do tests.
Either the data is embedded inside the script, or it is loaded via JSON-P

Categories

Resources