├── background.js
├── icons
├── main.png
├── 16x16.png
├── 48x48.png
└── 128x128.png
├── screenshots
├── clear-640x400.png
└── find-640x400.png
├── PRIVACY.md
├── manifest.json
├── popup.html
├── style.css
├── README.md
└── script.js
/background.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/icons/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Muhammad-Sarfaraz/ip2location/HEAD/icons/main.png
--------------------------------------------------------------------------------
/icons/16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Muhammad-Sarfaraz/ip2location/HEAD/icons/16x16.png
--------------------------------------------------------------------------------
/icons/48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Muhammad-Sarfaraz/ip2location/HEAD/icons/48x48.png
--------------------------------------------------------------------------------
/icons/128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Muhammad-Sarfaraz/ip2location/HEAD/icons/128x128.png
--------------------------------------------------------------------------------
/screenshots/clear-640x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Muhammad-Sarfaraz/ip2location/HEAD/screenshots/clear-640x400.png
--------------------------------------------------------------------------------
/screenshots/find-640x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Muhammad-Sarfaraz/ip2location/HEAD/screenshots/find-640x400.png
--------------------------------------------------------------------------------
/PRIVACY.md:
--------------------------------------------------------------------------------
1 | # Privacy Policy
2 |
3 | - Personal Data:
4 | ip2location neither collects nor will ever collect personal data or browsing history.
5 |
6 | In the future, ip2location may request permission to collect non-identifying information, such as browser version, platform name, display settings, and user's filter settings. This data will aid in improving features and user experience.
7 |
8 | - Third-Party Services:
9 | ip2location uses two external API, "http://ip-api.com/json","https://api64.ipify.org?format=json"
10 |
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 3,
3 | "name": "Ip2Location",
4 | "version": "1.0",
5 | "description": "Ip 2 Location: is a Chrome extension that offers precise geo-location data for any IP address",
6 | "permissions": [],
7 | "icons": {
8 | "16": "icons/16x16.png",
9 | "48": "icons/48x48.png",
10 | "128": "icons/128x128.png"
11 | },
12 | "background": {
13 | "service_worker": "background.js"
14 | },
15 | "action": {
16 | "default_popup": "popup.html",
17 | "default_icon": {
18 | "16": "icons/16x16.png",
19 | "48": "icons/48x48.png",
20 | "128": "icons/128x128.png"
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Ip 2 Location
10 |
11 |
12 |
13 |
14 |

15 |
Ip2Location
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: 'JetBrains Mono', monospace;
3 | background-color: #F4EEE0;
4 | min-width: 400px;
5 | }
6 |
7 | .danger {
8 | color: red;
9 | }
10 |
11 | input {
12 | width: 100%;
13 | padding: 10px;
14 | box-sizing: border-box;
15 | border: 1px solid #393646;
16 | margin-bottom: 4px;
17 | }
18 |
19 | button {
20 | cursor: pointer;
21 | background: #4F4557;
22 | color: rgb(252, 245, 235);
23 | padding: 10px 20px;
24 | border: none;
25 | font-weight: bold;
26 | border-radius: 5px;
27 | }
28 |
29 | button:hover {
30 | background-color: #393646;
31 | }
32 |
33 | ul {
34 | margin-top: 20px;
35 | list-style: none;
36 | padding-left: 0;
37 | }
38 |
39 | li {
40 | margin-top: 5px;
41 | }
42 |
43 | a {
44 | color: #393646;
45 | }
46 |
47 | .loader {
48 | width: 12px;
49 | height: 12px;
50 | border: 3px solid #FFF;
51 | border-bottom-color: transparent;
52 | border-radius: 100%;
53 | display: inline-block;
54 | box-sizing: border-box;
55 | animation: rotation 1s linear infinite;
56 | }
57 |
58 | @keyframes rotation {
59 | 0% {
60 | transform: rotate(0deg);
61 | }
62 | 100% {
63 | transform: rotate(360deg);
64 | }
65 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | [**→ Install now**](https://chromewebstore.google.com/detail/ip2location/dijmhdpmneceedgojcfmhaedhficbeek)
8 |
9 |
10 |
11 | # Ip To location [A Google Chrome Extension]
12 | 🌍 Ip2Location: Geolocate any IP address effortlessly.
13 |
14 |
15 |
16 | ## Installation
17 |
18 | You can install the extension via using git clone
19 |
20 | ```sh
21 | $ git clone https://github.com/Muhammad-Sarfaraz/ip2location.git
22 | ```
23 |
24 | Load the unpacked extension in chrome
25 | ```
26 | Settings->Extensions->Load unpacked
27 | ```
28 | Finally Published:
29 | ```
30 | https://chrome.google.com/webstore/detail/ip2location/dijmhdpmneceedgojcfmhaedhficbeek
31 | ```
32 |
33 | ## Special Thanks
34 | - Khushbunnahar Anita
35 | - Forhad Alam
36 | - & all the well wisher.
37 |
38 |
39 | ## Change log
40 |
41 | Please see the [changelog](CHANGELOG.md) for more information on what has changed recently.
42 |
43 | ## Contributing
44 |
45 | Please see [contributing.md](CONTRIBUTING.md) for details and a todolist.
46 |
47 | ## Security
48 |
49 | If you discover any security related issues, please email author email instead of using the issue tracker.
50 |
51 | ## Credits
52 |
53 | - Sarfaraz Muhammad Sajib
54 |
55 | ## License
56 |
57 | license. Please see the [license file](LICENCE.md) for more information.
58 |
--------------------------------------------------------------------------------
/script.js:
--------------------------------------------------------------------------------
1 | const inputEl = document.getElementById("inp-ip");
2 | const myLocationButton = document.getElementById("btn-my-location");
3 | const findButton = document.getElementById("btn-find");
4 | const clearButton = document.getElementById("btn-clear");
5 | const errorMsg = document.getElementById("error-msg");
6 | const endpointForLocation = "http://ip-api.com/json";
7 | const endpointForIp = "https://api64.ipify.org?format=json";
8 | let loading = false;
9 |
10 | function find(ip) {
11 | fetch(`${endpointForLocation}/${ip}`)
12 | .then((response) => response.json())
13 | .then((data) => {
14 | render(data);
15 | })
16 | .catch((error) => {
17 | console.error("Error:", error);
18 | })
19 | .finally(() => {
20 | setLoading(false,findButton,"Find");
21 | });
22 | }
23 |
24 | function render(data) {
25 | const ul = document.getElementById("ip-info");
26 | ul.innerHTML = `
27 | IP: ${data.query}
28 | City: ${data.city}
29 | Region: ${data.regionName}
30 | Country: ${data.country}
31 | ISP: ${data.isp}
32 | `;
33 | }
34 |
35 | function isValidIP(ip) {
36 | const ipPattern =
37 | /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
38 | return ipPattern.test(ip);
39 | }
40 |
41 | function setLoading(status,element=null,name= null) {
42 | if (status) {
43 | element.innerHTML = ''
44 | findButton.disabled = true;
45 | clearButton.disabled = true;
46 | myLocationButton.disabled = true;
47 | } else {
48 | element.innerHTML = name;
49 | findButton.disabled = false;
50 | clearButton.disabled = false;
51 | myLocationButton.disabled = false;
52 | }
53 | }
54 |
55 | inputEl.addEventListener("change", function () {
56 | errorMsg.innerHTML = "";
57 | });
58 |
59 | inputEl.addEventListener("input", function () {
60 | errorMsg.innerHTML = "";
61 | });
62 |
63 | myLocationButton.addEventListener("click", function () {
64 | setLoading(true,myLocationButton,"My Location");
65 | fetch(endpointForIp)
66 | .then((response) => response.json())
67 | .then((data) => {
68 | const ip = data.ip;
69 | find(ip);
70 | })
71 | .catch((error) => {
72 | console.error("Error:", error);
73 | })
74 | .finally(() => {
75 | setLoading(false,myLocationButton,"My Location");
76 | });
77 | });
78 |
79 | findButton.addEventListener("click", function () {
80 | const ip = inputEl.value;
81 | if (ip) {
82 | if (isValidIP(ip)) {
83 | setLoading(true,findButton,"Find");
84 | find(ip);
85 | } else {
86 | errorMsg.innerHTML = "Invalid Ip address!";
87 | }
88 | } else {
89 | errorMsg.innerHTML = "Ip address is required!";
90 | }
91 | });
92 |
93 | clearButton.addEventListener("click", function () {
94 | setLoading(true,clearButton,"Clear");
95 | errorMsg.innerHTML = "";
96 | inputEl.value = "";
97 | const ul = document.getElementById("ip-info");
98 | while (ul.firstChild) {
99 | ul.removeChild(ul.firstChild);
100 | }
101 | setLoading(false,clearButton,"Clear");
102 | });
103 |
--------------------------------------------------------------------------------