mirror of
https://github.com/Oreolek/TrackMeNot-Chrome.git
synced 2024-06-26 03:41:00 +03:00
Option fixes
This commit is contained in:
parent
3ec0e9ecfc
commit
2e63034140
|
@ -2,7 +2,7 @@
|
|||
"manifest_version": 2,
|
||||
"name": "TrackMeNot",
|
||||
"description": "TMN WebExtension portage",
|
||||
"version": "0.10.9",
|
||||
"version": "0.10.10",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"trackmenot.js"
|
||||
|
|
|
@ -47,26 +47,32 @@ TRACKMENOT.Menus = function() {
|
|||
|
||||
|
||||
onLoadMenu: function( ) {
|
||||
tmn = chrome.extension.getBackgroundPage().TRACKMENOT.TMNSearch;
|
||||
options = tmn._getOptions();
|
||||
tmn_option_query = tmn._getQuery();
|
||||
tmn_option_engine = tmn._getEngine();
|
||||
getting_tmn = browser.runtime.getBackgroundPage();
|
||||
getting_tmn.then(function(page){
|
||||
console.log(page);
|
||||
tmn = page.TRACKMENOT.TMNSearch;
|
||||
|
||||
$("#trackmenot-label").html(tmn_option_engine + " '"+ tmn_option_query+"'");
|
||||
if (tmn) {
|
||||
options = tmn._getOptions();
|
||||
tmn_option_query = tmn._getQuery();
|
||||
tmn_option_engine = tmn._getEngine();
|
||||
|
||||
$("#trackmenot-label").html(tmn_option_engine + " '"+ tmn_option_query+"'");
|
||||
}
|
||||
|
||||
if ( options.enabled) {
|
||||
$("#trackmenot-enabled").html('Disable');
|
||||
$("#trackmenot-img-enabled").attr("src", "images/skin/off_icon.png");
|
||||
} else {
|
||||
$("#trackmenot-enabled").html('Enable');
|
||||
$("#trackmenot-img-enabled").attr("src", "images/skin/on_icon.png");
|
||||
}
|
||||
if ( !tmn || options.enabled ) {
|
||||
$("#trackmenot-enabled").html('Disable');
|
||||
$("#trackmenot-img-enabled").attr("src", "images/skin/off_icon.png");
|
||||
} else {
|
||||
$("#trackmenot-enabled").html('Enable');
|
||||
$("#trackmenot-img-enabled").attr("src", "images/skin/on_icon.png");
|
||||
}
|
||||
|
||||
if (options.useTab)
|
||||
$("#trackmenot-menu-useTab").html('Stealth');
|
||||
else
|
||||
$("#trackmenot-menu-useTab").html('Tab');
|
||||
if (!tmn || options.useTab)
|
||||
$("#trackmenot-menu-useTab").html('Stealth');
|
||||
else
|
||||
$("#trackmenot-menu-useTab").html('Tab');
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
@ -74,7 +80,7 @@ TRACKMENOT.Menus = function() {
|
|||
document.addEventListener('DOMContentLoaded', function () {
|
||||
$("#trackmenot-menu-useTab").click(TRACKMENOT.Menus.toggleTabFrame);
|
||||
$("#trackmenot-enabled").click(TRACKMENOT.Menus.toggleOnOff);
|
||||
$("#trackmenot-menu-win").click(function() { window.open(chrome.extension.getURL('options.html'));});
|
||||
$("#trackmenot-menu-win").click(function() { window.open(browser.extension.getURL('options.html'));});
|
||||
$("#trackmenot-menu-help").click(TRACKMENOT.Menus.showHelp);
|
||||
TRACKMENOT.Menus.onLoadMenu();
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
let tmn_options ={};
|
||||
let getting_tmn = browser.runtime.getBackgroundPage()
|
||||
let tmn = undefined;
|
||||
let getting_tmn = browser.runtime.getBackgroundPage();
|
||||
let tmn;
|
||||
getting_tmn.then(function(page) {
|
||||
tmn = page.TRACKMENOT.TMNSearch;
|
||||
})
|
||||
});
|
||||
let options = null;
|
||||
|
||||
function loadHandlers() {
|
||||
|
@ -52,7 +52,7 @@ function loadHandlers() {
|
|||
'engine':del_engine
|
||||
});
|
||||
setTimeout(function() {
|
||||
window.location.reload()
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
|
@ -78,7 +78,7 @@ function loadHandlers() {
|
|||
'engine': engine
|
||||
});
|
||||
setTimeout(function() {
|
||||
window.location.reload()
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
@ -150,6 +150,9 @@ function TMNShowLog() {
|
|||
}
|
||||
|
||||
function TMNShowEngines(engines) {
|
||||
if (!engines) {
|
||||
return;
|
||||
}
|
||||
let htmlStr = "<table>";
|
||||
for (let i=0; i < engines.length; i++) {
|
||||
let engine = engines[i];
|
||||
|
@ -322,7 +325,11 @@ function handleRequest(request, sender, sendResponse) {
|
|||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
TMNShowEngines(tmn._getTargetEngines());
|
||||
if (tmn) {
|
||||
TMNShowEngines(tmn._getTargetEngines());
|
||||
} else {
|
||||
TMNShowEngines();
|
||||
}
|
||||
TMNSetOptionsMenu();
|
||||
loadHandlers();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"fullName" : "TrackMeNot",
|
||||
"license": "GPL 2.0",
|
||||
"author": "Daniel Howe, Helen Nissenbaum, Vincent Toubiana",
|
||||
"version": "0.10.9",
|
||||
"version": "0.10.10",
|
||||
"homepage": "http://www.cs.nyu.edu/trackmenot/",
|
||||
"icon":"data/images/skin/tmn.png",
|
||||
"main": "trackmenot",
|
||||
|
|
|
@ -20,11 +20,12 @@ if(!TRACKMENOT)
|
|||
var TRACKMENOT = {};
|
||||
|
||||
TRACKMENOT.TMNSearch = function() {
|
||||
let debug_ = true;
|
||||
|
||||
let tmn_tab_id = -1;
|
||||
let tmn_tab = null;
|
||||
let useTab = false;
|
||||
let enabled = true;
|
||||
let debug_ = false;
|
||||
let load_full_pages = false;
|
||||
let last_url = "";
|
||||
let stop_when = "start";
|
||||
|
@ -526,7 +527,7 @@ TRACKMENOT.TMNSearch = function() {
|
|||
*/
|
||||
function randomQuery() {
|
||||
let randomElt = function (arr) {
|
||||
if (arr === null) {
|
||||
if (!arr) {
|
||||
console.trace();
|
||||
return arr;
|
||||
}
|
||||
|
@ -541,6 +542,9 @@ TRACKMENOT.TMNSearch = function() {
|
|||
TMNQueries[type] !== null &&
|
||||
TMNQueries[type].length > 0
|
||||
) {
|
||||
if (TMNQueries[type][0].words && TMNQueries[type][0].words.length === 0) {
|
||||
continue;
|
||||
}
|
||||
typeoffeeds.push(type);
|
||||
}
|
||||
}
|
||||
|
@ -557,8 +561,12 @@ TRACKMENOT.TMNSearch = function() {
|
|||
}
|
||||
let term = trim( queries );
|
||||
if (!term || term.length === 0) {
|
||||
if (debug_)
|
||||
if (debug_) {
|
||||
console.log(queries);
|
||||
console.log(qtype);
|
||||
console.log(typeoffeeds);
|
||||
throw new Error("getQuery.term='"+term+"'");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return term;
|
||||
|
@ -792,19 +800,16 @@ TRACKMENOT.TMNSearch = function() {
|
|||
function getSubQuery(queryWords) {
|
||||
let incQuery = "";
|
||||
let randomArray = [];
|
||||
for (let k = 0; k < queryWords.length ; k++) {
|
||||
for (let k = 0; k < queryWords.length && k < 5; k++) {
|
||||
let randomIndex = roll(0,queryWords.length-1);
|
||||
if ( randomArray.indexOf(randomIndex) < 0)
|
||||
randomArray.push(randomIndex);
|
||||
}
|
||||
randomArray.sort();
|
||||
for (let k = 0; k < randomArray.length-1 && k < 5; k++) {
|
||||
for (let k = 0; k < randomArray.length-1; k++) {
|
||||
incQuery += queryWords[randomArray[k]]+' ';
|
||||
}
|
||||
incQuery += queryWords[randomArray[k]];
|
||||
if (incQueries) {
|
||||
incQueries.push(trim(incQuery));
|
||||
}
|
||||
incQueries.push(trim(incQuery));
|
||||
}
|
||||
|
||||
function getQuery() {
|
||||
|
@ -1093,7 +1098,13 @@ TRACKMENOT.TMNSearch = function() {
|
|||
function restoreOptions () {
|
||||
let getter = browser.storage.local.get("options_tmn");
|
||||
getter.then(function(item) {
|
||||
let options = JSON.parse(item.options_tmn);
|
||||
let options;
|
||||
try {
|
||||
options = JSON.parse(item.options_tmn);
|
||||
} catch (e) {
|
||||
resetOptions();
|
||||
return;
|
||||
}
|
||||
enabled = options.enabled;
|
||||
debug("Restore: "+ enabled);
|
||||
useBlackList = options.use_black_list;
|
||||
|
@ -1121,18 +1132,30 @@ TRACKMENOT.TMNSearch = function() {
|
|||
});
|
||||
let querygetter = browser.storage.local.get("gen_queries");
|
||||
querygetter.then(function(item){
|
||||
TMNQueries = JSON.parse(item.gen_queries);
|
||||
try {
|
||||
TMNQueries = JSON.parse(item.gen_queries);
|
||||
} catch (e) {
|
||||
TMNQueries = {};
|
||||
}
|
||||
});
|
||||
let loggetter = browser.storage.local.get("logs_tmn");
|
||||
loggetter.then(function(item){
|
||||
tmnLogs = JSON.parse(item.logs_tmn);
|
||||
if (typeof tmnLogs === "object") {
|
||||
tmnLogs = Object.keys(tmnLogs).map(x => tmnLogs[x]);
|
||||
try {
|
||||
tmnLogs = JSON.parse(item.logs_tmn);
|
||||
if (typeof tmnLogs === "object") {
|
||||
tmnLogs = Object.keys(tmnLogs).map(x => tmnLogs[x]);
|
||||
}
|
||||
} catch (e) {
|
||||
tmnLogs = [];
|
||||
}
|
||||
});
|
||||
let enginegetter = browser.storage.local.get("engines");
|
||||
enginegetter.then(function(item){
|
||||
engines = JSON.parse(item.engines);
|
||||
try {
|
||||
engines = JSON.parse(item.engines);
|
||||
} catch (e) {
|
||||
resetOptions();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue