зеркало из https://github.com/mozilla/lightbeam.git
First cut, ready to include everything as content scripts
This commit is contained in:
Родитель
f21e2f95d1
Коммит
acf3be13f6
|
@ -2,7 +2,8 @@
|
|||
|
||||
// Visualization of tracking data interconnections
|
||||
|
||||
(function(global){
|
||||
(function(global) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// An emitter that lists nodes and edges so we can build the data structure
|
||||
|
@ -40,7 +41,7 @@ function resetData(){
|
|||
aggregate.trackerCount = 0;
|
||||
aggregate.siteCount = 0;
|
||||
aggregate.recentSites = [];
|
||||
currentVisualization.emit('reset');
|
||||
global.currentVisualization.emit('reset');
|
||||
updateStatsBar();
|
||||
}
|
||||
aggregate.on('reset', resetData);
|
||||
|
@ -132,40 +133,46 @@ aggregate.connectionAsObject = function(conn){
|
|||
// visualizations.
|
||||
function onLoad(connections){
|
||||
var startTime = Date.now();
|
||||
console.log("aggregate::onLoad", connections.length, "connections", aggregate.currentFilter);
|
||||
connections.forEach(onConnection);
|
||||
if (connections) {
|
||||
console.log("aggregate::onLoad", connections.length, "connections", aggregate.currentFilter);
|
||||
connections.forEach(onConnection);
|
||||
}
|
||||
aggregate.initialized = true;
|
||||
filteredAggregate = aggregate.filters[aggregate.currentFilter]();
|
||||
|
||||
// Tell the visualization that we're ready.
|
||||
currentVisualization.emit('init');
|
||||
if (global.currentVisualization) {
|
||||
global.currentVisualization.emit('init');
|
||||
}
|
||||
updateStatsBar();
|
||||
console.log('aggregate::onLoad end, took %s ms', Date.now() - startTime);
|
||||
}
|
||||
|
||||
function setPrefs(prefs) {
|
||||
console.log("in aggregate prefs");
|
||||
global.setPrefs(prefs);
|
||||
if (global.setPrefs) {
|
||||
global.setPrefs(prefs);
|
||||
}
|
||||
}
|
||||
|
||||
aggregate.on('load', onLoad);
|
||||
aggregate.on("setPrefs", setPrefs);
|
||||
|
||||
// Constants for indexes of properties in array format
|
||||
//const SOURCE = 0;
|
||||
//const TARGET = 1;
|
||||
//const TIMESTAMP = 2;
|
||||
//const CONTENT_TYPE = 3;
|
||||
//const COOKIE = 4;
|
||||
//const SOURCE_VISITED = 5;
|
||||
//const SECURE = 6;
|
||||
//const SOURCE_PATH_DEPTH = 7;
|
||||
//const SOURCE_QUERY_DEPTH = 8;
|
||||
//const SOURCE_SUB = 9;
|
||||
//const TARGET_SUB = 10;
|
||||
//const METHOD = 11;
|
||||
//const STATUS = 12;
|
||||
//const CACHEABLE = 13;
|
||||
const SOURCE = 0;
|
||||
const TARGET = 1;
|
||||
const TIMESTAMP = 2;
|
||||
const CONTENT_TYPE = 3;
|
||||
const COOKIE = 4;
|
||||
const SOURCE_VISITED = 5;
|
||||
const SECURE = 6;
|
||||
const SOURCE_PATH_DEPTH = 7;
|
||||
const SOURCE_QUERY_DEPTH = 8;
|
||||
const SOURCE_SUB = 9;
|
||||
const TARGET_SUB = 10;
|
||||
const METHOD = 11;
|
||||
const STATUS = 12;
|
||||
const CACHEABLE = 13;
|
||||
|
||||
// Check that recent sites include the domain. This is another potential source
|
||||
// of false positives.
|
||||
|
@ -499,7 +506,7 @@ var debounce = function debounce(func, wait, immediate) {
|
|||
|
||||
aggregate.update = debounce(function update(){
|
||||
// FIXME: maybe not for list view
|
||||
if (currentVisualization.name !== 'graph'){
|
||||
if (global.currentVisualization && global.currentVisualization.name !== 'graph'){
|
||||
console.log('do not update aggregate for %s view', currentVisualization.name);
|
||||
}
|
||||
if (aggregate.initialized){
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
(function(global) {
|
||||
|
||||
// This is the e10s/message passing content script that ties the workers to the
|
||||
// addon. It can see most of the addon, the window is either not visible or not
|
||||
// mutable so we use unsafeWindow below. This handles the post message
|
||||
// connections and does a little UI work on the side.
|
||||
self.port.on('log', function log(args) {
|
||||
if (unsafeWindow && unsafeWindow.console) {
|
||||
unsafeWindow.console.log.call(unsafeWindow, args);
|
||||
} else {
|
||||
console.log('cannot call browser logging: ' + unsafeWindow);
|
||||
}
|
||||
});
|
||||
|
||||
self.port.on('connection', function(connection) {
|
||||
if (unsafeWindow && unsafeWindow.aggregate) {
|
||||
unsafeWindow.allConnections.push(connection);
|
||||
global.allConnections.push(connection);
|
||||
unsafeWindow.aggregate.emit('connection', connection);
|
||||
} else {
|
||||
console.log('cannot call unsafeWindow.aggregate: ' + unsafeWindow);
|
||||
|
@ -20,9 +14,9 @@ self.port.on('connection', function(connection) {
|
|||
});
|
||||
|
||||
self.port.on('passStoredConnections', function(connections) {
|
||||
global.allConnections = connections;
|
||||
if (unsafeWindow) {
|
||||
unsafeWindow.allConnections = connections;
|
||||
unsafeWindow.aggregate.emit('load', unsafeWindow.allConnections);
|
||||
unsafeWindow.aggregate.emit('load', global.allConnections);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -43,18 +37,14 @@ self.port.on('update-blocklist-all', function(domains) {
|
|||
});
|
||||
|
||||
self.port.on('init', function() {
|
||||
console.error('content-script::init()');
|
||||
console.log('content-script::init()');
|
||||
if (unsafeWindow && unsafeWindow.aggregate && !unsafeWindow.aggregate.initialized) {
|
||||
unsafeWindow.aggregate.emit('load', unsafeWindow.allConnections);
|
||||
unsafeWindow.aggregate.emit('load', global.allConnections);
|
||||
} else {
|
||||
console.error('cannot call unsafeWindow.aggregate: %s', unsafeWindow);
|
||||
}
|
||||
});
|
||||
|
||||
self.port.on("private-browsing", function() {
|
||||
unsafeWindow.informUserOfUnsafeWindowsDialog();
|
||||
});
|
||||
|
||||
self.port.on("setPrefs", function(prefs) {
|
||||
console.log("Got set prefs", prefs);
|
||||
if (unsafeWindow && unsafeWindow.aggregate) {
|
||||
|
@ -63,10 +53,10 @@ self.port.on("setPrefs", function(prefs) {
|
|||
console.error("cannot call aggregate.setPrefs");
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
unsafeWindow.addon = self.port;
|
||||
console.log('Added "addon" to unsafeWindow');
|
||||
} catch (e) {
|
||||
console.error('unable to add "addon" to unsafeWindow: %s', e);
|
||||
}
|
||||
})(this);
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
|
||||
// Visualization of tracking data interconnections
|
||||
|
||||
(function(visualizations){
|
||||
(function(visualizations, global){
|
||||
"use strict";
|
||||
|
||||
// Bunch of utilities related to UI elements.
|
||||
const graphNodeRadius = {
|
||||
"graph": 12
|
||||
};
|
||||
|
||||
// The graph is an emitter with a default size.
|
||||
var graph = new Emitter();
|
||||
|
@ -46,7 +50,7 @@ function onUpdate(){
|
|||
force.links(filteredAggregate.edges);
|
||||
force.start();
|
||||
updateGraph();
|
||||
colourHighlightNodes(highlight);
|
||||
global.colourHighlightNodes(highlight);
|
||||
}else{
|
||||
console.log('the force is not with us');
|
||||
}
|
||||
|
@ -80,7 +84,7 @@ function onRemove(){
|
|||
|
||||
function onReset(){
|
||||
onRemove();
|
||||
aggregate.emit('load', allConnections);
|
||||
aggregate.emit('load', global.allConnections);
|
||||
}
|
||||
|
||||
// UTILITIES FOR CREATING POLYGONS
|
||||
|
@ -123,6 +127,11 @@ function nodeName(node){
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
global.siteHasPref = function siteHasPref(site,pref){
|
||||
return (Object.keys(userSettings).indexOf(site) > -1 &&
|
||||
userSettings[site].contains(pref));
|
||||
}
|
||||
|
||||
function watchSite(node){
|
||||
return siteHasPref(node.name,"watch");
|
||||
}
|
||||
|
@ -136,6 +145,29 @@ var ticking = false;
|
|||
|
||||
function charge(d){ return -(500 + d.weight * 25); }
|
||||
|
||||
global.colourHighlightNodes = function colourHighlightNodes(highlight){
|
||||
var watchedSites = document.querySelectorAll(".watched");
|
||||
var blockedSites = document.querySelectorAll(".blocked");
|
||||
if ( highlight.watched ){
|
||||
for (var i=0; i<watchedSites.length; i++){
|
||||
watchedSites[i].classList.add("watchedSites");
|
||||
}
|
||||
}else{
|
||||
for (var i=0; i<watchedSites.length; i++){
|
||||
watchedSites[i].classList.remove("watchedSites");
|
||||
}
|
||||
}
|
||||
if ( highlight.blocked ){
|
||||
for (var i=0; i<blockedSites.length; i++){
|
||||
blockedSites[i].classList.add("blockedSites");
|
||||
}
|
||||
}else{
|
||||
for (var i=0; i<blockedSites.length; i++){
|
||||
blockedSites[i].classList.remove("blockedSites");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initGraph(){
|
||||
// Initialize D3 layout and bind data
|
||||
// console.log('initGraph()');
|
||||
|
@ -302,7 +334,9 @@ function resetCanvas(){
|
|||
|
||||
var graphLegend = document.querySelector(".graph-footer");
|
||||
|
||||
legendBtnClickHandler(graphLegend);
|
||||
if (global.legendBtnClickHandler) {
|
||||
global.legendBtnClickHandler(graphLegend);
|
||||
}
|
||||
|
||||
graphLegend.querySelector(".legend-toggle-visited").addEventListener("click", function(event){
|
||||
var visited = document.querySelectorAll(".visitedYes");
|
||||
|
@ -344,4 +378,4 @@ graphLegend.querySelector(".legend-toggle").addEventListener("click", function(e
|
|||
});
|
||||
|
||||
|
||||
})(visualizations);
|
||||
})(visualizations, this);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
(function(global) {
|
||||
// Used for managing the DOM for infobar part of the page
|
||||
'use strict';
|
||||
|
||||
function initMap(){
|
||||
global.initMap = function initMap(mapcanvas, mapDocument){
|
||||
|
||||
var oriMapViewBox = mapcanvas.getAttribute('viewBox');
|
||||
|
||||
|
@ -316,4 +317,4 @@ function hideAllInfoPanelContentExcept(elmToShow){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
})(this);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
(function(global) {
|
||||
|
||||
'use strict';
|
||||
|
||||
const roundOffFactor = 5*60*1000; // in milliseconds
|
||||
var visualizations = {};
|
||||
var currentVisualization;
|
||||
var currentFilter;
|
||||
var allConnections = [];
|
||||
var isRobot = false; // Used for spidering the web only
|
||||
var userSettings = {};
|
||||
var allConnections = [];
|
||||
|
||||
// Constants for indexes of properties in array format
|
||||
const SOURCE = 0;
|
||||
|
@ -30,9 +30,16 @@ var mapDocument, mapcanvas;
|
|||
document.querySelector('.world-map').addEventListener('load', function(event){
|
||||
mapDocument = event.target.contentDocument;
|
||||
mapcanvas = mapDocument.querySelector('.mapcanvas');
|
||||
initMap();
|
||||
initMap(mapcanvas, mapDocument);
|
||||
}, false);
|
||||
|
||||
// Export everything
|
||||
global.visualizations = visualizations;
|
||||
global.currentVisualization = currentVisualization;
|
||||
global.currentFilter = currentFilter;
|
||||
global.userSettings = userSettings;
|
||||
global.vizcanvas = vizcanvas;
|
||||
global.allConnections = allConnections;
|
||||
|
||||
// DOM Utility
|
||||
|
||||
|
@ -161,12 +168,19 @@ function formattedDate(date,format){
|
|||
}
|
||||
|
||||
|
||||
function singularOrPluralNoun(num,str){
|
||||
if ( typeof num != "number" ){
|
||||
num = parseFloat(num);
|
||||
}
|
||||
return ( num > 1) ? str+"s" : str;
|
||||
}
|
||||
|
||||
/****************************************
|
||||
* update Stats Bar
|
||||
*/
|
||||
function updateStatsBar(){
|
||||
global.updateStatsBar = function updateStatsBar(){
|
||||
var dateSince = "just now";
|
||||
if ( allConnections.length > 0 ){
|
||||
if (global.allConnections.length > 0 ){
|
||||
dateSince = formattedDate(allConnections[0][2]);
|
||||
}
|
||||
document.querySelector(".top-bar .date-gathered").textContent = dateSince;
|
||||
|
@ -174,5 +188,4 @@ function updateStatsBar(){
|
|||
document.querySelector(".top-bar .first-party-sites").textContent = aggregate.siteCount + " " + singularOrPluralNoun(aggregate.siteCount,"SITE");
|
||||
}
|
||||
|
||||
|
||||
|
||||
})(this);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Display data in tabular format
|
||||
|
||||
(function(visualizations){
|
||||
(function(visualizations, global){
|
||||
|
||||
var list = new Emitter();
|
||||
var breadcrumbStack = [];
|
||||
|
@ -23,7 +23,7 @@ function onReset(){
|
|||
console.log("reset list");
|
||||
breadcrumbStack = [];
|
||||
onRemove();
|
||||
aggregate.emit('load', allConnections);
|
||||
aggregate.emit('load', global.allConnections);
|
||||
}
|
||||
|
||||
function onInit(){
|
||||
|
@ -608,4 +608,4 @@ function toggleShowHideHiddenButton(){
|
|||
}
|
||||
}
|
||||
|
||||
})(visualizations);
|
||||
})(visualizations, this);
|
||||
|
|
88
data/ui.js
88
data/ui.js
|
@ -1,10 +1,13 @@
|
|||
(function(global) {
|
||||
// Bunch of utilities related to UI elements.
|
||||
const graphNodeRadius = {
|
||||
"graph": 12
|
||||
};
|
||||
|
||||
global.graphNodeRadius = graphNodeRadius;
|
||||
|
||||
/* Convert a NodeList to Array */
|
||||
function toArray(nl){
|
||||
global.toArray = function toArray(nl){
|
||||
return Array.prototype.slice.call(nl, 0);
|
||||
}
|
||||
|
||||
|
@ -67,8 +70,6 @@ btnGroupArray.forEach(function(btnGroup){
|
|||
|
||||
/* Share Data Toggle */
|
||||
|
||||
var shareDataToggle = document.querySelector(".toggle-btn.share-btn");
|
||||
|
||||
document.querySelector(".toggle-btn.share-btn").addEventListener("click",
|
||||
function(event){
|
||||
var elmClicked = event.target;
|
||||
|
@ -81,7 +82,7 @@ document.querySelector(".toggle-btn.share-btn").addEventListener("click",
|
|||
}
|
||||
});
|
||||
|
||||
function confirmStartSharing(askForConfirmation, elmClicked) {
|
||||
global.confirmStartSharing = function confirmStartSharing(askForConfirmation, elmClicked) {
|
||||
startSharing(askForConfirmation, function(confirmed) {
|
||||
if (confirmed) {
|
||||
toggleBtnOnEffect(document.querySelector(".share-btn") );
|
||||
|
@ -92,7 +93,7 @@ function confirmStartSharing(askForConfirmation, elmClicked) {
|
|||
});
|
||||
}
|
||||
|
||||
function confirmStopSharing(elmClicked) {
|
||||
global.confirmStopSharing = function confirmStopSharing(elmClicked) {
|
||||
stopSharingDialog(function(confirmed) {
|
||||
if (confirmed) {
|
||||
toggleBtnOffEffect(document.querySelector(".share-btn"));
|
||||
|
@ -153,7 +154,7 @@ document.querySelector('.reset-data').addEventListener('click', function(){
|
|||
});
|
||||
});
|
||||
|
||||
function getZoom(canvas){
|
||||
global.getZoom = function getZoom(canvas){
|
||||
try{
|
||||
var box = canvas.getAttribute('viewBox')
|
||||
.split(/\s/)
|
||||
|
@ -165,7 +166,7 @@ function getZoom(canvas){
|
|||
}
|
||||
}
|
||||
|
||||
function setZoom(box,canvas){
|
||||
global.setZoom = function setZoom(box,canvas){
|
||||
// TODO: code cleanup if both cases use basically the same code
|
||||
canvas.setAttribute('viewBox', [box.x, box.y, box.w, box.h].join(' '));
|
||||
}
|
||||
|
@ -184,8 +185,8 @@ const mapZoomOutLimit = { w:2711.3, h:1196.7 };
|
|||
const svgZoomingRatio = 1.1;
|
||||
|
||||
document.querySelector(".stage").addEventListener("wheel",function(event){
|
||||
if ( event.target.mozMatchesSelector(".vizcanvas, .vizcanvas *") && currentVisualization.name != "list" ){
|
||||
if ( currentVisualization.name == "graph" ){
|
||||
if ( event.target.mozMatchesSelector(".vizcanvas, .vizcanvas *") && global.currentVisualization.name != "list" ){
|
||||
if ( global.currentVisualization.name == "graph" ){
|
||||
zoomWithinLimit(event.deltaY, vizcanvas, graphZoomInLimit, graphZoomOutLimit);
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +300,7 @@ document.querySelector(".stage").addEventListener("mouseleave",function(event){
|
|||
|
||||
/* Legend & Controls ===================================== */
|
||||
|
||||
function toggleLegendSection(eventTarget,legendElm){
|
||||
global.toggleLegendSection = function toggleLegendSection(eventTarget,legendElm){
|
||||
var elmToToggle = legendElm.querySelector(".legend-controls");
|
||||
if ( elmToToggle.classList.contains("hidden") ){
|
||||
elmToToggle.classList.remove("hidden");
|
||||
|
@ -310,13 +311,13 @@ function toggleLegendSection(eventTarget,legendElm){
|
|||
}
|
||||
}
|
||||
|
||||
function toggleVizElements(elements,classToggle){
|
||||
global.toggleVizElements = function toggleVizElements(elements,classToggle){
|
||||
toArray(elements).forEach(function(elm){
|
||||
elm.classList.toggle(classToggle);
|
||||
});
|
||||
}
|
||||
|
||||
function legendBtnClickHandler(legendElm){
|
||||
global.legendBtnClickHandler = function legendBtnClickHandler(legendElm){
|
||||
legendElm.querySelector(".legend-controls").addEventListener("click", function(event){
|
||||
if (event.target.mozMatchesSelector(".btn, .btn *")){
|
||||
var btn = event.target;
|
||||
|
@ -332,19 +333,19 @@ function legendBtnClickHandler(legendElm){
|
|||
|
||||
/* Glowing Effect for Graph/Clock & Highlighting Effect for List ============= */
|
||||
|
||||
function selectedNodeEffect(name){
|
||||
if ( currentVisualization.name == "graph") {
|
||||
global.selectedNodeEffect = function selectedNodeEffect(name){
|
||||
if ( global.currentVisualization.name == "graph") {
|
||||
resetAllGlow("all");
|
||||
addGlow(name,"selected");
|
||||
}
|
||||
if ( currentVisualization.name == "list" ){
|
||||
if ( global.currentVisualization.name == "list" ){
|
||||
resetHighlightedRow();
|
||||
}
|
||||
}
|
||||
|
||||
function connectedNodeEffect(name){
|
||||
global.connectedNodeEffect = function connectedNodeEffect(name){
|
||||
// console.log(name);
|
||||
if ( currentVisualization.name != "list" ){
|
||||
if ( global.currentVisualization.name != "list" ){
|
||||
var glow = document.querySelector(".connected-glow");
|
||||
while( glow ){
|
||||
glow = document.querySelector(".connected-glow");
|
||||
|
@ -362,9 +363,9 @@ function connectedNodeEffect(name){
|
|||
}
|
||||
|
||||
// for Graph & Clock
|
||||
function addGlow(name,type){
|
||||
globa..addGlow = function addGlow(name,type){
|
||||
type = ( type == "selected") ? "selected-glow" : "connected-glow";
|
||||
var viz = currentVisualization.name;
|
||||
var viz = global.currentVisualization.name;
|
||||
var gNodes = document.querySelectorAll(".node[data-name='"+name+"']");
|
||||
toArray(gNodes).forEach(function(gNode){
|
||||
var glowProps = calculateGlowSize(gNode,viz);
|
||||
|
@ -379,11 +380,11 @@ function addGlow(name,type){
|
|||
});
|
||||
}
|
||||
|
||||
function calculateGlowSize(gNode,viz){
|
||||
global.calculateGlowSize = function calculateGlowSize(gNode,viz){
|
||||
var glowProps = {};
|
||||
var siteNode = gNode.childNodes[0];
|
||||
var shape = siteNode.nodeName.toLowerCase();
|
||||
var radius = graphNodeRadius[currentVisualization.name];
|
||||
var radius = graphNodeRadius[global.currentVisualization.name];
|
||||
if ( viz == "graph" ){
|
||||
if ( shape == "polygon" ) radius *= 2.2;
|
||||
glowProps.radius = radius + 22;
|
||||
|
@ -398,7 +399,7 @@ function calculateGlowSize(gNode,viz){
|
|||
}
|
||||
|
||||
// for Graph
|
||||
function resetAllGlow(type){
|
||||
global.resetAllGlow = function resetAllGlow(type){
|
||||
var selectedGlow;
|
||||
var connectedGlow;
|
||||
if ( type == "selected" || type == "all"){
|
||||
|
@ -416,7 +417,7 @@ function resetAllGlow(type){
|
|||
}
|
||||
|
||||
// for List
|
||||
function resetHighlightedRow(){
|
||||
global.resetHighlightedRow = function resetHighlightedRow(){
|
||||
var preHighlighted = document.querySelector(".list-table .selected-connected-row");
|
||||
if ( preHighlighted ){
|
||||
preHighlighted.classList.remove("selected-connected-row");
|
||||
|
@ -426,7 +427,7 @@ function resetHighlightedRow(){
|
|||
/**************************************************
|
||||
* Singular / Plural Noun
|
||||
*/
|
||||
function singularOrPluralNoun(num,str){
|
||||
global.singularOrPluralNoun = function singularOrPluralNoun(num,str){
|
||||
if ( typeof num != "number" ){
|
||||
num = parseFloat(num);
|
||||
}
|
||||
|
@ -436,38 +437,10 @@ function singularOrPluralNoun(num,str){
|
|||
/**************************************************
|
||||
* Check if a site has certain preference set to it
|
||||
*/
|
||||
function siteHasPref(site,pref){
|
||||
return (Object.keys(userSettings).indexOf(site) > -1 &&
|
||||
userSettings[site].contains(pref));
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
* When initializing Graph View / Clock View
|
||||
* if the "Watched Sites" or "Blocked Sites" toggles are on, apply colour to the corresponding nodes
|
||||
*/
|
||||
function colourHighlightNodes(highlight){
|
||||
var watchedSites = document.querySelectorAll(".watched");
|
||||
var blockedSites = document.querySelectorAll(".blocked");
|
||||
if ( highlight.watched ){
|
||||
for (var i=0; i<watchedSites.length; i++){
|
||||
watchedSites[i].classList.add("watchedSites");
|
||||
}
|
||||
}else{
|
||||
for (var i=0; i<watchedSites.length; i++){
|
||||
watchedSites[i].classList.remove("watchedSites");
|
||||
}
|
||||
}
|
||||
if ( highlight.blocked ){
|
||||
for (var i=0; i<blockedSites.length; i++){
|
||||
blockedSites[i].classList.add("blockedSites");
|
||||
}
|
||||
}else{
|
||||
for (var i=0; i<blockedSites.length; i++){
|
||||
blockedSites[i].classList.remove("blockedSites");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setPrefs(event) {
|
||||
console.log("Setting content script prefs", JSON.stringify(event));
|
||||
if ("contributeData" in event) {
|
||||
|
@ -481,7 +454,12 @@ function setPrefs(event) {
|
|||
}
|
||||
}
|
||||
if ("defaultVisualization" in event) {
|
||||
currentVisualization = visualizations[event["defaultVisualization"]];
|
||||
global.currentVisualization = visualizations[event["defaultVisualization"]];
|
||||
if (global.currentVisualization) {
|
||||
console.log("Got viz");
|
||||
} else {
|
||||
console.error("NO viz");
|
||||
}
|
||||
}
|
||||
// This is not working quite
|
||||
if ("defaultFilter" in event) {
|
||||
|
@ -492,3 +470,7 @@ function setPrefs(event) {
|
|||
document.querySelector(".btn_group.session").querySelector("[data-selected]").textContent;
|
||||
}
|
||||
}
|
||||
|
||||
// Exports
|
||||
global.setPrefs = setPrefs;
|
||||
})(this);
|
||||
|
|
Загрузка…
Ссылка в новой задаче