forked from noble-8/browserFingerPrintSpoofing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
// background.js | ||
|
||
let color = '#3aa757'; | ||
|
||
chrome.runtime.onInstalled.addListener(() => { | ||
chrome.storage.sync.set({ color }); | ||
console.log('Default background color set to %cgreen', `color: ${color}`); | ||
}); | ||
|
||
|
||
chrome.storage.sync.set({ UA_CHANGED: false }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +0,0 @@ | ||
button { | ||
height: 30px; | ||
width: 30px; | ||
outline: none; | ||
margin: 10px; | ||
border: none; | ||
border-radius: 2px; | ||
} | ||
|
||
button.current { | ||
box-shadow: 0 0 0 2px white, | ||
0 0 0 4px black; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
{ | ||
"name": "Getting Started Example", | ||
"description": "Build an Extension!", | ||
"version": "1.0", | ||
"manifest_version": 3, | ||
"background": { | ||
"service_worker": "background.js" | ||
}, | ||
"permissions": ["storage", "activeTab", "scripting"], | ||
"action": { | ||
"default_popup": "popUp.html" | ||
}, | ||
"default_icon": { | ||
"16": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started16.png", | ||
"32": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started32.png", | ||
"48": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started48.png", | ||
"128":"/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started128.png" | ||
}, | ||
"default_icon": { | ||
"16": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started16.png", | ||
"32": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started32.png", | ||
"48": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started48.png", | ||
"128": "/home/akash/Documents/repos/browserFingerPrintSpoofing/images/get_started128.png" | ||
} | ||
"name": "Getting Started Example", | ||
"description": "Build an Extension!", | ||
"version": "1.0", | ||
"manifest_version": 3, | ||
"background": { | ||
"service_worker": "background.js" | ||
}, | ||
"permissions": [ | ||
"scripting", | ||
"storage", | ||
"declarativeNetRequest", | ||
"declarativeNetRequestWithHostAccess" | ||
], | ||
"host_permissions": ["<all_urls>"], | ||
"action": { | ||
"default_popup": "popup.html", | ||
"default_icon": { | ||
"16": "./images/get_started16.png", | ||
"32": "./images/get_started32.png", | ||
"48": "./images/get_started48.png", | ||
"128": "./images/get_started128.png" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="button.css" /> | ||
</head> | ||
<body> | ||
<button id="change-ua"></button> | ||
<script src="popup.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,63 @@ | ||
// Initialize button with user's preferred color | ||
let changeColor = document.getElementById("changeColor"); | ||
actionBtn = document.querySelector("#change-ua"); | ||
|
||
chrome.storage.sync.get("color", ({ color }) => { | ||
changeColor.style.backgroundColor = color; | ||
chrome.storage.sync.get("UA_CHANGED", ({ UA_CHANGED }) => { | ||
actionBtn.textContent = UA_CHANGED ? "Stop" : "Change UA"; | ||
}); | ||
// When the button is clicked, inject setPageBackgroundColor into current page | ||
changeColor.addEventListener("click", async () => { | ||
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true }); | ||
|
||
chrome.scripting.executeScript({ | ||
target: { tabId: tab.id }, | ||
function: setPageBackgroundColor, | ||
}); | ||
actionBtn.addEventListener("click", (event) => { | ||
chrome.storage.sync.get("UA_CHANGED", ({ UA_CHANGED }) => { | ||
userAgentChanged = UA_CHANGED; | ||
const newValue = !UA_CHANGED; | ||
chrome.storage.sync.set({ UA_CHANGED: newValue }, async () => { | ||
let userAgent = ""; | ||
if (!newValue) { | ||
userAgent = window.navigator.userAgent; | ||
actionBtn.textContent = "Change UA"; | ||
} else { | ||
userAgent = await getRandomUserAgent(); | ||
actionBtn.textContent = "Stop"; | ||
} | ||
chrome.declarativeNetRequest.updateDynamicRules( | ||
{ | ||
removeRuleIds: [1], | ||
addRules: [ | ||
{ | ||
id: 1, | ||
priority: 10, | ||
action: { | ||
type: "modifyHeaders", | ||
requestHeaders: [ | ||
{ | ||
header: "user-agent", | ||
operation: "set", | ||
value: userAgent, | ||
}, | ||
], | ||
}, | ||
condition: { | ||
urlFilter: "*", | ||
resourceTypes: ["main_frame"], | ||
}, | ||
}, | ||
], | ||
}, | ||
() => { | ||
reload(); | ||
} | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
// The body of this function will be executed as a content script inside the | ||
// current page | ||
function setPageBackgroundColor() { | ||
chrome.storage.sync.get("color", ({ color }) => { | ||
document.body.style.backgroundColor = color; | ||
}); | ||
async function reload() { | ||
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true }); | ||
chrome.tabs.reload(tab.id); | ||
} | ||
|
||
async function getRandomUserAgent() { | ||
const response = await fetch( | ||
"https://browser-fingerprint-spoof.herokuapp.com/getRandomUserAgent" | ||
); | ||
let userAgent = await response.text(); | ||
return userAgent; | ||
} |