I am new to this and I followed official tutorial.
I made a folder in my desktop named as Chrome and put all files manifest.json, popup.html, icon.png there along with a file guestbook.pl. Now the content of manifest.json is same as given in above link but I changed the code of popup.html according to my need which is:
<html>
<head>
<title>Guestbook</title>
</head>
<body>
<form action="/home/chankey/Desktop/Chrome/guestbook.pl" method="get">
<table>
<tr><td>Name</td><td><input name="name" type="text" value=""></td></tr>
<tr><td>E-Mail</td><td><input name="email" type="text" value=""></td></tr>
<tr><td>Location</td><td><input name="loc" type="text" value=""></td></tr>
<tr><td>Comments</td><td>
<TEXTAREA name="comments" rows="10" cols="32"></TEXTAREA></td></tr>
</table><br><br>
<input type="submit" value="Add Entry">
</form>
</body>
</html>
Then I added the extension on my Google Chrome. Extension added successfully and when I click on it a form appears (from popup.html) but when I click on "Add Entry" button to submit the data the script (guestbook.pl) doesn’t run. A new page appears which says
This web page has not been found, No web page was found for the web address: chrome-extension://plkeijfkmjeakkbdclipkoadchbpgpdm/home/chankey/Desktop/Chrome/guestbook.pl?name=&email=&loc=&comments=
Why is this happening? The script is in the same directory then why isn’t chrome finding it?
guestbook.pl
#!/usr/bin/perl
my $query_string = "";
#Get the input
if ($ENV{REQUEST_METHOD} eq 'POST') {
read(STDIN, $query_string, $ENV{CONTENT_LENGTH});
} else {
$query_string = $ENV{QUERY_STRING};
}
##### We will remove this
print "Content-Type: text/html\n\n";
print "Query String is \n<br> $query_string";
print "hi";
##### We will remove this
You can’t run Perl in Chrome. Chrome extensions are small web pages and can only use client-side web technologies. Therefore, the language you use is JavaScript.
To create a guestbook style extension you’d have to run your guestbook.pl script on a web server and then use AJAX calls from JavaScript in the extension to save and get the data.