Last active
December 21, 2019 16:36
-
-
Save hitGovernor/e467e906c705edcd9544577a3806b52a to your computer and use it in GitHub Desktop.
Consoles out a table of all resources blocked by Ensighten's Privacy Gateway
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
if (typeof (gateway) != "undefined") { | |
/** | |
* consoles out the provided array using the provided status as a header | |
* @param status {string} | |
* @param output {array} | |
*/ | |
function gwLogger(status, output) { | |
if (output.length > 0) { | |
console.log(status + " REQUESTS:"); | |
console.table(output); | |
} else { | |
console.log(status + " REQUESTS:\n-- none"); | |
}; | |
}; | |
var blocked = [], | |
notBlocked = []; | |
// loop through history object, separating out blocked and non-blocked resources | |
for (var id in gateway.history.complete) { | |
var item = { | |
// id: id, | |
destination: gateway.history.complete[id].request.destination, | |
type: gateway.history.complete[id].request.type, | |
source: gateway.history.complete[id].request.source, | |
status: gateway.history.complete[id].request.status, | |
reasons: JSON.stringify(gateway.history.complete[id].request.reasons, null, 0), | |
list: JSON.stringify(gateway.history.complete[id].request.list, null, 0) | |
} | |
if (item.status === "blocked") { | |
blocked.push(item); | |
} else { | |
notBlocked.push(item); | |
} | |
} | |
// display findings in console | |
gwLogger("BLOCKED", blocked); | |
gwLogger("OTHER (ALLOWED)", notBlocked); | |
} else { | |
console.log("Ensighten's Privacy gateway object was not detected."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated gist to reference gateway.history.complete object, reducing code by half. Output now includes significantly more information.