Skip to content

Commit

Permalink
Revert "Fixed urls checked twice"
Browse files Browse the repository at this point in the history
This reverts commit c5f899c.
  • Loading branch information
davtur19 committed Aug 31, 2023
1 parent c5f899c commit b6d5c67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 48 deletions.
76 changes: 29 additions & 47 deletions dotgit.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,7 @@ chrome.storage.local.get(["checked", "withExposedGit", "options"], function (res

set_options(result.options);

chrome.webRequest.onHeadersReceived.addListener(async function (details) {
await processListener(details)
}, {urls: ["<all_urls>"]});
chrome.webRequest.onHeadersReceived.addListener(details => processListener(details), {urls: ["<all_urls>"]});
chrome.webRequest.onErrorOccurred.addListener(details => checkDomtakeover(details, result), {urls: ["<all_urls>"]});

});
Expand All @@ -668,56 +666,47 @@ chrome.storage.local.set({
});


async function processListener(details) {
function processListener(details) {
if (!(check_git || check_svn || check_hg || check_env)) {
return;
}

let origin = new URL(details["url"])["origin"];
await processSearch(origin);
if (queue_req.isEmpty() === true) {
chrome.storage.local.get(["checked", "withExposedGit"], result => processSearch(result, origin));
} else {
queue_listener.enqueue(origin);
}
}


function checkUrl(origin, callback) {
function checkUrl(storage, origin) {
let hostname = new URL(origin)["hostname"];

if (origin.startsWith("chrome-extension")) {
callback(false);
return;
return false;
}

chrome.storage.local.get(["checked"], function (result) {
if (result.checked && !result.checked.includes(origin) && checkBlacklist(hostname) === false) {
callback(true);
} else {
callback(false);
}
});
return (storage.checked.includes(origin) === false && checkBlacklist(hostname) === false);
}


async function processSearch(origin) {
//alert('processSearch');
checkUrl(origin, async function (result) {
if (result) {
if (queue_running === false) {
queue_running = true;
await queue_req.enqueue(origin);
while (queue_listener.isEmpty() === false) {
let origin2 = queue_listener.dequeue();
checkUrl(origin, async function (result2) {
if (result2) {
await queue_req.enqueue(origin2);
}
});
async function processSearch(storage, origin) {
if (checkUrl(storage, origin)) {
if (queue_running === false) {
queue_running = true;
queue_req.enqueue(origin);
while (queue_listener.isEmpty() === false) {
let origin2 = queue_listener.dequeue();
if (checkUrl(storage, origin2)) {
queue_req.enqueue(origin2);
}
await precessQueue();
queue_running = false;
} else {
await queue_listener.enqueue(origin);
}
await precessQueue(storage);
queue_running = false;
} else {
queue_listener.enqueue(origin);
}
});
}
}


Expand All @@ -727,14 +716,10 @@ function Queue() {
console.log(collection);
};
this.enqueue = function (element) {
checkUrl(element, function (result) {
if (result) {
// works for strings not objects
if (collection.indexOf(element) === -1) {
collection.push(element);
}
}
});
// works for strings not objects
if (collection.indexOf(element) === -1) {
collection.push(element);
}
};
this.dequeue = function () {
return collection.shift();
Expand All @@ -748,13 +733,10 @@ function Queue() {
this.isEmpty = function () {
return (collection.length === 0);
};
this.inQueue = function (element) {
return (collection.indexOf(element) !== -1);
}
}


async function precessQueue() {
async function precessQueue(visitedSite) {
while (queue_req.isEmpty() !== true) {
let url = queue_req.front();
let securitytxt = null;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "DotGit",
"version": "4.7.2",
"version": "4.7.1",
"description": "An extension for checking if .git is exposed in visited websites",
"icons": {
"16": "icons/dotgit-16.png",
Expand Down

0 comments on commit b6d5c67

Please sign in to comment.