update
This commit is contained in:
1 parent
0f0d371afd
commit
bf84195925
5 files changed
+81
-14
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
all:
|
||||||
|
rm -f selenium_helper.xpi
|
||||||
|
zip -x "*.xpi" -x "Makefile" -r selenium_helper.zip .
|
||||||
|
mv selenium_helper.zip selenium_helper.xpi
|
||||||
@@ -68,6 +68,37 @@ function set_proxy(PROXY) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function set_headers(HEADERS) {
|
||||||
|
|
||||||
|
function rewriteRequestHeader(requestDetails) {
|
||||||
|
|
||||||
|
for (let key in HEADERS) {
|
||||||
|
to_modify = {"name": key, "value": HEADERS[key]};
|
||||||
|
|
||||||
|
is_set = false;
|
||||||
|
|
||||||
|
for (let header of requestDetails.requestHeaders) {
|
||||||
|
if (header.name.toLowerCase() === to_modify.name.toLowerCase()) {
|
||||||
|
header.value = to_modify.value;
|
||||||
|
is_set = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_set) {
|
||||||
|
requestDetails.requestHeaders.push(to_modify)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {requestHeaders: requestDetails.requestHeaders}
|
||||||
|
}
|
||||||
|
|
||||||
|
const TARGET = "<all_urls>";
|
||||||
|
chrome.webRequest.onBeforeSendHeaders.addListener(rewriteRequestHeader,
|
||||||
|
{ urls: [TARGET] },
|
||||||
|
["blocking", "requestHeaders"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|
||||||
function setProxy(result) {
|
function setProxy(result) {
|
||||||
@@ -84,10 +115,20 @@ function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setHeaders(result) {
|
||||||
|
if (result.headers) {
|
||||||
|
console.log("Setup headers...");
|
||||||
|
set_headers(result.headers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
console.log(`Error: ${error}`);
|
console.log(`Error: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let headers = browser.storage.sync.get("headers");
|
||||||
|
headers.then(setHeaders, onError);
|
||||||
|
|
||||||
let proxy = browser.storage.sync.get("proxy");
|
let proxy = browser.storage.sync.get("proxy");
|
||||||
proxy.then(setProxy, onError);
|
proxy.then(setProxy, onError);
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -4,13 +4,14 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form id="options_form" method="POST">
|
<form id="options_form" method="POST">
|
||||||
<input type="text" name="type" id="type">
|
<input type="text" id="type">
|
||||||
<input type="text" name="host" id="host">
|
<input type="text" id="host">
|
||||||
<input type="text" name="port" id="port">
|
<input type="text" id="port">
|
||||||
<input type="text" name="username" id="username">
|
<input type="text" id="username">
|
||||||
<input type="text" name="password" id="password">
|
<input type="text" id="password">
|
||||||
<input id="submit" type="submit" value="Submit">
|
<input type="submit" id="submit" value="Submit">
|
||||||
<textarea id="cookies" name="cookies"></textarea>
|
<textarea id="cookies"></textarea>
|
||||||
|
<textarea id="headers"></textarea>
|
||||||
</form>
|
</form>
|
||||||
<script src="options.js"></script>
|
<script src="options.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+27
-1
@@ -1,9 +1,13 @@
|
|||||||
function saveOptions(e) {
|
function saveOptions(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let cookies = [];
|
let cookies = [];
|
||||||
|
let headers = [];
|
||||||
try {
|
try {
|
||||||
cookies = JSON.parse(document.getElementById("cookies").value);
|
cookies = JSON.parse(document.getElementById("cookies").value);
|
||||||
} catch {};
|
} catch {};
|
||||||
|
try {
|
||||||
|
headers = JSON.parse(document.getElementById("headers").value);
|
||||||
|
} catch {};
|
||||||
console.log(cookies)
|
console.log(cookies)
|
||||||
browser.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
proxy: {
|
proxy: {
|
||||||
@@ -13,8 +17,21 @@ function saveOptions(e) {
|
|||||||
"username": document.getElementById("username").value,
|
"username": document.getElementById("username").value,
|
||||||
"password": document.getElementById("password").value
|
"password": document.getElementById("password").value
|
||||||
},
|
},
|
||||||
cookies: cookies
|
cookies: cookies,
|
||||||
|
headers: headers
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function saveOptionsEx(proxy, cookies, headers) {
|
||||||
|
browser.storage.sync.set({
|
||||||
|
proxy: proxy,
|
||||||
|
cookies: cookies,
|
||||||
|
headers: headers
|
||||||
|
});
|
||||||
|
browser.runtime.sendMessage({"update": true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -36,10 +53,19 @@ function restoreOptions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCurrentHeaders(result) {
|
||||||
|
if (result.headers) {
|
||||||
|
document.getElementById("headers").value = JSON.stringify(result.headers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
console.log(`Error: ${error}`);
|
console.log(`Error: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let headers = browser.storage.sync.get("headers");
|
||||||
|
headers.then(setCurrentHeaders, onError);
|
||||||
|
|
||||||
let proxy = browser.storage.sync.get("proxy");
|
let proxy = browser.storage.sync.get("proxy");
|
||||||
proxy.then(setCurrentProxy, onError);
|
proxy.then(setCurrentProxy, onError);
|
||||||
|
|
||||||
|
|||||||
+1
-6
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"version": "0.0.4",
|
"version": "0.0.6",
|
||||||
"minimum_chrome_version": "76.0",
|
"minimum_chrome_version": "76.0",
|
||||||
"applications": {
|
"applications": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
@@ -29,11 +29,6 @@
|
|||||||
"options_ui": {
|
"options_ui": {
|
||||||
"page": "data/options.html"
|
"page": "data/options.html"
|
||||||
},
|
},
|
||||||
"browser_specific_settings": {
|
|
||||||
"gecko": {
|
|
||||||
"id": "eet1ra8cauDu@AlexandrSokolov"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["data/content.js"]
|
"scripts": ["data/content.js"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user