Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	manifest.json
#	options.html
#	tmn_search.js
#	trackmenot.js
  • Loading branch information
Vincent Toubiana committed Apr 7, 2017
2 parents 4f11071 + bc03239 commit 8a12b60
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 83 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"permissions": [
"tabs","https://*/*","webNavigation","storage"
"tabs","https://*/*","http://*/*","webNavigation","storage"
]
}

11 changes: 9 additions & 2 deletions menu-script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
var api;
if (chrome == 'undefined') {
api = browser;
} else {
api = chrome;
}

if(!TRACKMENOT) var TRACKMENOT = {};

TRACKMENOT.Menus = function() {
Expand Down Expand Up @@ -38,7 +45,7 @@ TRACKMENOT.Menus = function() {


onLoadMenu: function( ) {
tmn = chrome.extension.getBackgroundPage().TRACKMENOT.TMNSearch;
tmn = api.extension.getBackgroundPage().TRACKMENOT.TMNSearch;
options = tmn._getOptions(); ;
tmn_option_query = tmn._getQuery();
tmn_option_engine = tmn._getEngine();
Expand All @@ -63,7 +70,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(api.extension.getURL('options.html'));});
$("#trackmenot-menu-help").click(TRACKMENOT.Menus.showHelp)
TRACKMENOT.Menus.onLoadMenu()
});
30 changes: 18 additions & 12 deletions option-script.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@

var api;
if (chrome == 'undefined') {
api = browser;
} else {
api = chrome;
}

var tmn_options ={};
var tmn = chrome.extension.getBackgroundPage().TRACKMENOT.TMNSearch;
var tmn = api.extension.getBackgroundPage().TRACKMENOT.TMNSearch;
var options = null;

function loadHandlers() {
$("#apply-options").click( function() {
tmn_options = {"options":saveOptions()};
TMNSetOptionsMenu(tmn_options);
alert("Configuration saved");
chrome.runtime.sendMessage({'tmn':"TMNSaveOptions",'option':tmn_options.options});
api.runtime.sendMessage({'tmn':"TMNSaveOptions",'option':tmn_options.options});
}
);

$("#trackmenot-opt-help").click( function() {
chrome.runtime.sendMessage({'tmn':"TMNOptionsOpenHelp"});
api.runtime.sendMessage({'tmn':"TMNOptionsOpenHelp"});
}
);

$("#trackmenot-opt-site").click( function() {
chrome.runtime.sendMessage({'tmn':"TMNOptionsOpenSite"});
api.runtime.sendMessage({'tmn':"TMNOptionsOpenSite"});

}
);
Expand All @@ -28,31 +34,31 @@ function loadHandlers() {
}
);
$("#show-log").click( function() {
chrome.runtime.sendMessage({'tmn':"TMNOptionsShowLog"});
api.runtime.sendMessage({'tmn':"TMNOptionsShowLog"});
}
);

$("#trackmenot-opt-showqueries").click( function() {
chrome.runtime.sendMessage({'tmn':"TMNOptionsShowQueries"});
api.runtime.sendMessage({'tmn':"TMNOptionsShowQueries"});
}
);

$("#validate-feed").click( function() {
var feeds = $("#trackmenot-seed").val();
var param = {"feeds": feeds}
chrome.runtime.sendMessage({'tmn':"TMNValideFeeds",'param':param});
api.runtime.sendMessage({'tmn':"TMNValideFeeds",'param':param});
}
);

$("#clear-log").click( function() {
chrome.runtime.sendMessage({'tmn':"TMNOptionsClearLog"});
api.runtime.sendMessage({'tmn':"TMNOptionsClearLog"});
}
);


$("#search-engine-list").on('click', 'button.smallbutton', function(event) {
var del_engine = event.target.id.split("_").pop();
chrome.runtime.sendMessage({'tmn':"TMNDelEngine",'engine':del_engine});
api.runtime.sendMessage({'tmn':"TMNDelEngine",'engine':del_engine});
});


Expand All @@ -65,7 +71,7 @@ function loadHandlers() {
alert("Did not find 'trackmenot' in the URL")
return
}
chrome.runtime.sendMessage({'tmn':"TMNAddEngine",'engine': engine});
api.runtime.sendMessage({'tmn':"TMNAddEngine",'engine': engine});
}
);
}
Expand Down Expand Up @@ -224,7 +230,7 @@ document.addEventListener('DOMContentLoaded', function () {



chrome.runtime.onMessage.addListener(handleRequest);
api.runtime.onMessage.addListener(handleRequest);
/*
self.port.on("TMNSetOptionsMenu",TMNSetOptionsMenu)
self.port.on("TMNSendLogs",TMNShowLog)
Expand Down
51 changes: 26 additions & 25 deletions tmn_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
********************************************************************************/

var api;
if (chrome == 'undefined') {
api = browser;
} else {
api = chrome;
}

if(!TRACKMENOT) var TRACKMENOT = {};


Expand Down Expand Up @@ -158,18 +165,15 @@ TRACKMENOT.TMNInjected = function() {

function pressEnter(elt) {
var timers = getTimingArray();
var evtDown = document.createEvent("KeyboardEvent");
evtDown.initKeyboardEvent( "keydown", true, true, document.defaultView, false, false, false, false, 13, 0 );
var evtDown = new KeyboardEvent( "keydown", {"keyCode":13});
window.setTimeout(function(){
elt.dispatchEvent(evtDown);
},timers[0])
var evtPress= document.createEvent("KeyboardEvent");
evtPress.initKeyboardEvent( "keypress", true, true, document.defaultView, false, false, false, false, 13, 0 );
var evtPress= new KeyboardEvent( "keypress", {"keyCode":13});
window.setTimeout(function(){
elt.dispatchEvent(evtPress);
},timers[1])
var evtUp = document.createEvent("KeyboardEvent");
evtUp.initKeyboardEvent( "keyup", true, true, document.defaultView, false, false, false, false, 13, 0 );
var evtUp = new KeyboardEvent( "keyup", {"keyCode":13});
window.setTimeout(function(){
elt.dispatchEvent(evtUp);
},timers[2])
Expand All @@ -181,15 +185,13 @@ TRACKMENOT.TMNInjected = function() {

function downKey(chara, searchBox) {
var charCode = chara[chara.length-1].charCodeAt(0)
var evtDown = document.createEvent("KeyboardEvent");
evtDown.initKeyboardEvent( "keydown", true, true, document.defaultView, false, false, false, false, 0, charCode );
var evtDown = new KeyboardEvent("keydown", {"charCode":charCode} );
searchBox.dispatchEvent(evtDown)
}

function pressKey(chara, searchBox) {
var charCode = chara[chara.length-1].charCodeAt(0)
var evtPress = document.createEvent("KeyboardEvent");
evtPress.initKeyboardEvent( "keypress", true, true, document.defaultView, false, false, false, false, 0, charCode );
var evtPress = new KeyboardEvent("keypress", {"charCode":charCode});
searchBox.dispatchEvent(evtPress)
}

Expand All @@ -201,8 +203,7 @@ TRACKMENOT.TMNInjected = function() {

function releaseKey(chara, searchBox) {
var charCode = chara[chara.length-1].charCodeAt(0)
var evtUp = document.createEvent("KeyboardEvent");
evtUp.initKeyboardEvent( "keyup", true, true, document.defaultView, false, false, false, false, 0, charCode );
var evtUp = new KeyboardEvent( "keyup", {"charCode":charCode});
searchBox.dispatchEvent(evtUp)
}

Expand Down Expand Up @@ -408,7 +409,7 @@ TRACKMENOT.TMNInjected = function() {
var response = {
url: window.location.href
};
chrome.runtime.sendMessage(response);
browser.runtime.sendMessage(response);
}

function queryToURL ( url, query) {
Expand Down Expand Up @@ -447,7 +448,7 @@ TRACKMENOT.TMNInjected = function() {
return encodedUrl;
} catch (ex) {
cout("Caught exception: "+ ex);
chrome.runtime.sendMessage({
browser.runtime.sendMessage({
"url": encodedUrl
});
return null;
Expand All @@ -474,7 +475,7 @@ TRACKMENOT.TMNInjected = function() {
return encodedUrl;
} catch (ex) {
cout("Caught exception: "+ ex);
chrome.runtime.sendMessage( {
browser.runtime.sendMessage( {
"url": encodedUrl
});
return null;
Expand Down Expand Up @@ -504,7 +505,7 @@ TRACKMENOT.TMNInjected = function() {
var engine = getEngineById(eng)
if ( engine && engine.urlmap != asearch ) {
engine.urlmap = asearch;
chrome.storage.locale.set({engines :JSON.stringify(engines)}) ;
browser.storage.locale.set({engines :JSON.stringify(engines)}) ;
var logEntry = createLog('URLmap', eng, null,null,null, asearch)
log(logEntry);
debug("Updated url fr search engine "+ eng + ", new url is "+asearch);
Expand Down Expand Up @@ -590,39 +591,39 @@ TRACKMENOT.TMNInjected = function() {
"tmn": "pageLoaded",
"html": document.defaultView.document.body.innerHTML
}
chrome.runtime.sendMessage(req);
browser.runtime.sendMessage(req);
}


function log(msg) {
chrome.runtime.sendMessage({tmnLog:msg} )
browser.runtime.sendMessage({tmnLog:msg} )
}

function updateStatus(msg) {
var req = {
"updateStatus": msg
}
chrome.runtime.sendMessage(req);
browser.runtime.sendMessage(req);
}

function setCurrentURLMap( eng, url ) {
var Eng_URL = eng + "--" + url;
var req = {
setURLMap: Eng_URL
}
chrome.runtime.sendMessage(req);
browser.runtime.sendMessage(req);
}

function notifyUserSearch(eng, url) {
// Here we update the regecxpfpor the queried engine
updateURLRegexp(eng, url);
chrome.runtime.sendMessage({
browser.runtime.sendMessage({
"userSearch": eng
} );
}

function getTMNCurrentURL() {
chrome.runtime.sendMessage({
browser.runtime.sendMessage({
tmn: "currentURL"
},
function(response) {
Expand All @@ -636,7 +637,7 @@ TRACKMENOT.TMNInjected = function() {
var message = {
"url": tmnCurrentURL
};
chrome.runtime.sendMessage( message);
browser.runtime.sendMessage( message);
sendPageLoaded();
}

Expand Down Expand Up @@ -670,7 +671,7 @@ TRACKMENOT.TMNInjected = function() {


checkIsActiveTab : function() {
chrome.runtime.sendMessage({
browser.runtime.sendMessage({
tmn: "isActiveTab"
}, function(response) {
if (response.isActive){
Expand Down Expand Up @@ -701,7 +702,7 @@ TRACKMENOT.TMNInjected = function() {
}
}();
TRACKMENOT.TMNInjected.checkIsActiveTab();
chrome.runtime.onMessage.addListener( TRACKMENOT.TMNInjected.handleRequest );
browser.runtime.onMessage.addListener( TRACKMENOT.TMNInjected.handleRequest );

/*self.port.on("TMNTabRequest", TRACKMENOT.TMNInjected.handleRequest );
self.port.on("TMNClickResult", TRACKMENOT.TMNInjected.clickResult );*/
Loading

0 comments on commit 8a12b60

Please sign in to comment.