-
Notifications
You must be signed in to change notification settings - Fork 35
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
459 changed files
with
17,100 additions
and
51,239 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 |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
/launch.bat | ||
/launch.sh | ||
/package.sh | ||
.DS_Store | ||
.vscode/launch.json |
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,22 @@ | ||
Traduire CookieViz (Français) | ||
=== | ||
|
||
La traduction de CookieViz se déroule en quelques étapes : | ||
* Copier/coller un fichier .json depuis le répertoire languages (fr.json/en.json) | ||
* Traduiser les contenus en respectant la structure et les noms des variables | ||
* Enregistrer le fichier sous la forme XX.json, XX correspondant deux caractères d'une langue suivant le standard [ISO 639-1](https://fr.wikipedia.org/wiki/Liste_des_codes_ISO_639-1) | ||
* Metter à jour la section "languages" du fichier browser.config.js à la racine de ce projet pour référencer cette nouvelle traduction. | ||
|
||
Envoyez nous vos contributions au travers via des "pull requests" ! | ||
|
||
|
||
Translate CookieViz (Français) | ||
=== | ||
|
||
The translation of CookieViz takes place in a few steps: | ||
* Copy / paste a .json file from the languages directory (fr.json / en.json) | ||
* Translate the contents while respecting the structure and the names of the variables | ||
* Save the file as XX.json, XX corresponding to two characters of a language according to the [ISO 639-1] standard (https://fr.wikipedia.org/wiki/Liste_des_codes_ISO_639-1) | ||
* Update the "languages" section of the browser.config.js file at the root of this project with the new translation. | ||
|
||
Send us your contributions through "pull requests"! |
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,133 @@ | ||
const psl = require('psl'); | ||
const getFavicons = require('get-website-favicon'); | ||
var favicons ={}; | ||
|
||
function extractHostname(url, keep_protocol) { | ||
let hostname; | ||
|
||
//find & remove protocol (http, ftp, etc.) and get hostname | ||
if (url.indexOf("//") > -1) { | ||
hostname = url.split('/')[2]; | ||
} | ||
else | ||
{ | ||
hostname = url.split('/')[0]; | ||
} | ||
|
||
//find & remove port number | ||
hostname = hostname.split(':')[0]; | ||
//find & remove "?" | ||
hostname = hostname.split('?')[0]; | ||
|
||
return hostname; | ||
} | ||
|
||
|
||
function processFaviconRequest(requestdetails) { | ||
//Parsing all cookies | ||
let initiator = psl.get(extractHostname(requestdetails.initiator)); | ||
let request_url = psl.get(extractHostname(requestdetails.url)); | ||
|
||
function checkFavicon(request) { | ||
if (request in favicons) { | ||
return; | ||
} | ||
favicons[request] = null; | ||
getFavicons(request).then(data => { | ||
db.transaction(function (tx) { | ||
const insert_query = 'INSERT OR IGNORE INTO favicons (website, favicon) VALUES (?,?)'; | ||
if (data.icons.length > 0) { | ||
favicons[request] = data.icons[0].src; | ||
tx.executeSql(insert_query, [request, data.icons[0].src]); | ||
} else { | ||
tx.executeSql(insert_query, [request, null]); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
if (initiator) checkFavicon(initiator); | ||
if (request_url) checkFavicon(request_url); | ||
} | ||
|
||
function initFaviconCrawler(){ | ||
db.transaction(function (tx) { | ||
tx.executeSql(`CREATE TABLE IF NOT EXISTS favicons ( | ||
website varchar(255) UNIQUE NOT NULL, | ||
favicon varchar(255) | ||
)`); | ||
|
||
}, errorHandler); | ||
|
||
db.transaction(function (tx) { | ||
const load_query = 'SELECT * FROM favicons'; | ||
tx.executeSql(load_query, [], async function (tx, results) { | ||
var len = results.rows.length, i; | ||
for (i = 0; i < len; i++) { | ||
const row = results.rows.item(i); | ||
favicons[row['website']]= row['favicon']; | ||
} | ||
}); | ||
}); | ||
|
||
// Read cookie | ||
chrome.webRequest.onBeforeSendHeaders.addListener(processFaviconRequest, { | ||
urls: ["*://*/*"] | ||
}, [] | ||
); | ||
} | ||
|
||
function deleteFaviconCrawler(){ | ||
chrome.webRequest.onBeforeSendHeaders.removeListener(processFaviconRequest); | ||
} | ||
|
||
async function cleanFaviconTrigger(){ | ||
return new Promise((resolve, reject) => { | ||
db.transaction(function (tx) { | ||
tx.executeSql("DELETE FROM favicons", [], function(tx){ | ||
favicons = {}; | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
async function get_all_favicons(){ | ||
return new Promise((resolve, reject) => { | ||
db.transaction(function (tx) { | ||
const load_query = 'SELECT * FROM favicons'; | ||
tx.executeSql(load_query, [], async function (tx, results) { | ||
const favicons = {}; | ||
var len = results.rows.length, i; | ||
for (i = 0; i < len; i++) { | ||
const row = results.rows.item(i); | ||
favicons[row['website']]= row['favicon']; | ||
} | ||
resolve(favicons); | ||
}); | ||
}); | ||
}, errorHandler); | ||
} | ||
|
||
|
||
// Template for plugins | ||
const plugins_favicon = { | ||
name : "favicons", | ||
description : "This plugins stores favicons of every website that send/receive requests", | ||
author:"linc", | ||
init:initFaviconCrawler, | ||
delete:deleteFaviconCrawler, | ||
clean:cleanFaviconTrigger, | ||
data:{ | ||
"get_all_favicons": get_all_favicons | ||
} | ||
} | ||
|
||
|
||
|
||
// Entry point of plugins | ||
export function plugins() { | ||
return plugins_favicon; | ||
} | ||
|
||
|
Oops, something went wrong.