Skip to content

Commit

Permalink
Merge pull request #3 from crismotinha/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
crismotinha committed Jul 8, 2017
2 parents bdb8938 + 1e7e883 commit d20b0e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
25 changes: 14 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const img = document.getElementsByTagName("IMG");

if (img[0].src) {
const apiUrl = 'https://api.ocr.space/parse/imageurl';
const apikey = 'helloworld';
const imgUrl = img[0].src;
const queryString = apiUrl +'?apikey=' + apikey + '&url=' + imgUrl;
const myRequest = new Request(queryString, {method: 'GET'});
for (let i = 0; i < img.length; i++){
if (img[i].src) {
const apiUrl = 'https://api.ocr.space/parse/imageurl';
const apikey = '538df4ddfd88957';
const imgUrl = img[i].src;
const queryString = apiUrl +'?apikey=' + apikey + '&url=' + imgUrl;
const myRequest = new Request(queryString, {method: 'GET'});

fetch(myRequest)
.then(function(response) { return response.json(); })
fetch(myRequest)
.then(function(response) { return response.json(); })
.then(function(data) {
const text = data.ParsedResults[0].ParsedText;
img[0].setAttribute('alt', text);
})
}
img[i].setAttribute('alt', text);
})
}
}

7 changes: 2 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{

"manifest_version": 1,
"manifest_version": 2,
"name": "ocr-extension",
"version": "1.0",
"description": "Recreates the webpage adding alt tag to images",
"version": "1.0",

"permissions": [
"<all_urls>",
"contextMenus",
"activeTab",
"tabs",
"*://developer.mozilla.org/*",
"about:debugging"
"tabs"
],

"content_scripts": [
Expand Down

0 comments on commit d20b0e5

Please sign in to comment.