diff --git a/main.js b/main.js index a0c4236..c750896 100644 --- a/main.js +++ b/main.js @@ -1,134 +1,136 @@ -/*jshint sub:true*/ -"use strict"; - -/** - * Function to handle saving of fingerprint and initial loading of API. - * @param check flag specify certain tasks 0 => Initial checking of whether the fingerprint exists in db. - */ -function savefingerprint(check) { - - var param = ""; - var client = new ClientJS(); // Create A New Client Object - var fingerprint = client.getFingerprint(); // Calculate Device/Browser Fingerprint - - // Constructing GET Params - if (check === 0) { - // Checks whether the fingerprint already exists in DB. - param = encodeURI("?finger=" + fingerprint + "&check=1"); - } else { - // Saves the name with fingerprint to DB. - var name = document.getElementById("name").value; - - if (!name.trim()) { - name = "NoNameEntered :D"; - } - param = encodeURI("?finger=" + fingerprint + "&name=" + name); - } - - // Constructing request - var xhr = new XMLHttpRequest(); - var url = window.location.protocol + "//nothingprivate.000webhostapp.com/safedb.php"; - - xhr.onreadystatechange = function () { - if (this.readyState === 4 && this.status === 200) { - var arr = JSON.parse(this.responseText); - if (arr['status'] === 0) { - // Fingerprint already exists. - rendernewtabpage(arr['name']); - } else if (arr['status'] === 1) { - // Fingerprint saved successfully - rendersubmit(name); - } else if (arr['status'] === 3) { - // New user. No fingerprint found in the DB. - rendermain(); - } - } - }; - xhr.open("GET", url + param); - xhr.onerror = function () { - errorHandler(); // Error handler - }; - xhr.send(); -} - -/** - * Function to remove the saved fingerprint from the database. - */ -function forgetme() { - var client = new ClientJS(); // Create A New Client Object - var fingerprint = client.getFingerprint(); // Calculate Device/Browser Fingerprint - - // Param - var param = encodeURI("?finger=" + fingerprint); - - // Constructing request - var xhr = new XMLHttpRequest(); - var url = window.location.protocol + "//nothingprivate.000webhostapp.com/forgetme.php"; - - xhr.onreadystatechange = function () { - if (this.readyState === 4 && this.status === 200) { - var responsetext = JSON.parse(this.responseText); - if (responsetext['state'] === 1) { - document.getElementById("user").innerHTML = 'Are you Anonymous?'; - rendermain(); - } - } - }; - xhr.open("GET", url + param); - xhr.onerror = function () { - errorHandler(); // Error handler - }; - xhr.send(); -} - -/** - * Renders the page when the fingerprint is found in the db with the users name. - * @param name saved name of the user in the DB - */ -function rendernewtabpage(name) { - document.getElementById("maindiv").innerHTML = '

Welcome back to the website ' + htmlEncode(name) + '. If I can remember your name even though you are using private browsing / incognito mode, I can surely track you.

This is what big companies are doing. They are spying on you even when you are using private browsing or incognito mode.

Read more



If you liked this project, don\'t forget to give it a Star:

'; - document.getElementById("user").innerHTML = 'You are ' + htmlEncode(name) + '!'; -} - -/** - * Function to encode HYML value to prevent XSS Attack. - * @param value Value to encode - * @return {string} encoded value - */ -function htmlEncode(value){ - // Code to prevent xss attack - var temp_div = document.createElement("div"); - temp_div.textContent = value; - return temp_div.innerHTML; -} - -/** - * Renders the page after submitting the fingerprint to the API - * @param name - */ -function rendersubmit(name) { - document.getElementById("maindiv").innerHTML = '

Thank you, ' + htmlEncode(name) + '! Let\'s see the magic...

Now open a private browsing window or incognito window on your browser and visit www.nothingprivate.ml to see the magic...





'; - -} - -/** - * Renders the page on initial loading of the page (No fingerprint is found) - */ -function rendermain() { - document.getElementById("maindiv").innerHTML = '

Do you think that switching to your browser\'s private browsing mode or incognito mode will make you anonymous?

Sorry to disappoint you, but you are wrong!. Everyone can track you. You can check it out for yourself. Just type your name below.




'; -} - -/** - * Redo the API Call on clicking the retry button - */ -function reload() { - document.getElementById("maindiv").innerHTML = '

Loading... please wait...

'; - savefingerprint(0); -} - -/** - * Error handling code - */ -function errorHandler() { - document.getElementById("maindiv").innerHTML = '

An API error occurred! Please try again.

Nothing Private is using free hosting (00Webhost) to host the APIs.

It doesn\'t guarantee 100% uptime. Sorry for the inconvenience caused.





'; -} +/*jshint sub:true*/ +"use strict"; + +/** + * Function to handle saving of fingerprint and initial loading of API. + * @param check flag specify certain tasks 0 => Initial checking of whether the fingerprint exists in db. + */ + +const API_ROOT = window.location.protocol + "//nothingprivate.000webhostapp.com"; + +function savefingerprint(check) { + var param = ""; + var client = new ClientJS(); // Create A New Client Object + var fingerprint = client.getFingerprint(); // Calculate Device/Browser Fingerprint + + // Constructing GET Params + if (check === 0) { + // Checks whether the fingerprint already exists in DB. + param = encodeURI("?finger=" + fingerprint + "&check=1"); + } else { + // Saves the name with fingerprint to DB. + var name = document.getElementById("name").value; + + if (!name.trim()) { + name = "NoNameEntered :D"; + } + param = encodeURI("?finger=" + fingerprint + "&name=" + name); + } + + // Constructing request + var xhr = new XMLHttpRequest(); + var url = API_ROOT + "/safedb.php"; + + xhr.onreadystatechange = function () { + if (this.readyState === 4 && this.status === 200) { + var arr = JSON.parse(this.responseText); + if (arr['status'] === 0) { + // Fingerprint already exists. + rendernewtabpage(arr['name']); + } else if (arr['status'] === 1) { + // Fingerprint saved successfully + rendersubmit(name); + } else if (arr['status'] === 3) { + // New user. No fingerprint found in the DB. + rendermain(); + } + } + }; + xhr.open("GET", url + param); + xhr.onerror = function () { + errorHandler(); // Error handler + }; + xhr.send(); +} + +/** + * Function to remove the saved fingerprint from the database. + */ +function forgetme() { + var client = new ClientJS(); // Create A New Client Object + var fingerprint = client.getFingerprint(); // Calculate Device/Browser Fingerprint + + // Param + var param = encodeURI("?finger=" + fingerprint); + + // Constructing request + var xhr = new XMLHttpRequest(); + var url = API_ROOT + "/forgetme.php"; + + xhr.onreadystatechange = function () { + if (this.readyState === 4 && this.status === 200) { + var responsetext = JSON.parse(this.responseText); + if (responsetext['state'] === 1) { + document.getElementById("user").innerHTML = 'Are you Anonymous?'; + rendermain(); + } + } + }; + xhr.open("GET", url + param); + xhr.onerror = function () { + errorHandler(); // Error handler + }; + xhr.send(); +} + +/** + * Renders the page when the fingerprint is found in the db with the users name. + * @param name saved name of the user in the DB + */ +function rendernewtabpage(name) { + document.getElementById("maindiv").innerHTML = '

Welcome back to the website ' + htmlEncode(name) + '. If I can remember your name even though you are using private browsing / incognito mode, I can surely track you.

This is what big companies are doing. They are spying on you even when you are using private browsing or incognito mode.

Read more



If you liked this project, don\'t forget to give it a Star:

'; + document.getElementById("user").innerHTML = 'You are ' + htmlEncode(name) + '!'; +} + +/** + * Function to encode HYML value to prevent XSS Attack. + * @param value Value to encode + * @return {string} encoded value + */ +function htmlEncode(value){ + // Code to prevent xss attack + var temp_div = document.createElement("div"); + temp_div.textContent = value; + return temp_div.innerHTML; +} + +/** + * Renders the page after submitting the fingerprint to the API + * @param name + */ +function rendersubmit(name) { + document.getElementById("maindiv").innerHTML = '

Thank you, ' + htmlEncode(name) + '! Let\'s see the magic...

Now open a private browsing window or incognito window on your browser and visit www.nothingprivate.ml to see the magic...





'; + +} + +/** + * Renders the page on initial loading of the page (No fingerprint is found) + */ +function rendermain() { + document.getElementById("maindiv").innerHTML = '

Do you think that switching to your browser\'s private browsing mode or incognito mode will make you anonymous?

Sorry to disappoint you, but you are wrong!. Everyone can track you. You can check it out for yourself. Just type your name below.




'; +} + +/** + * Redo the API Call on clicking the retry button + */ +function reload() { + document.getElementById("maindiv").innerHTML = '

Loading... please wait...

'; + savefingerprint(0); +} + +/** + * Error handling code + */ +function errorHandler() { + document.getElementById("maindiv").innerHTML = '

An API error occurred! Please try again.

Nothing Private is using free hosting (00Webhost) to host the APIs.

It doesn\'t guarantee 100% uptime. Sorry for the inconvenience caused.





'; +}