I want to create a Google chrome extension that detects phishing sites by checking the site in the database of Phishtank. How do I go by the JavaScript codes using JSON and Ajax?
2 Answers
Not too sure what you had in mind for the search, but the way to get the URL of the current tab the user is in using the chrome.tabs.query.
Remember to include the 'tabs' permission in your manifest.json
...
"permissions": [
"tabs"
],
...
Also note that content_script cannot use most APIs so the chrome.tabs.query will have to be done in either the background_script or the popup_script.
Hopefully this helped a little.

- 47
- 7
-
Thanks. But that is not what I want. Let's say after it has gotten the current url, it should check into the databases of Phishtank. If the website can be found there, then it should alert the user. – Neron May 28 '18 at 21:57
For checking every URL, I think in your background script have a tabs.onUpdated listener to check for every time the url changes, which then runs a function to check the url, and if the url is a phishing url set a warning icon on the extension icon for that tab.
For using that API look at Send POST data using XMLHttpRequest for how to use POST with request parameters
List of things to look up:
https://developer.chrome.com/extensions/tabs#event-onUpdated
Send POST data using XMLHttpRequest
https://developer.chrome.com/extensions/browserAction#method-setIcon
Hope that helps

- 196
- 1
- 7