Skip to content

Commit

Permalink
unhack untrackification
Browse files Browse the repository at this point in the history
  • Loading branch information
akatrevorjay committed Aug 22, 2018
1 parent cedab3e commit 8d32896
Show file tree
Hide file tree
Showing 21 changed files with 1,083 additions and 1,369 deletions.
26 changes: 13 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>

<head>
<meta charset="utf-8">
<meta name="twitter:widgets:csp" content="on">

<title>Enhanced History</title>
<!-- build:css styles/app.css -->
<link rel='stylesheet' type='text/css' href='bower_components/chrome-bootstrap/chrome-bootstrap.css'/>
<link rel='stylesheet' type='text/css' href='styles/app.css'/>
<link rel='stylesheet' type='text/css' href='styles/i18n.css'/>

<!-- build:css styles/app.css -->
<link rel='stylesheet' type='text/css' href='bower_components/chrome-bootstrap/chrome-bootstrap.css' />
<link rel='stylesheet' type='text/css' href='styles/app.css' />
<link rel='stylesheet' type='text/css' href='styles/i18n.css' />
<!-- endbuild -->
</head>
<body class="chrome-bootstrap">
</head>

<body class="chrome-bootstrap">
<div class="app"></div>

<!-- build:js scripts/app.js -->
<script src='bower_components/chrome-historian/src/historian.js'></script>
<script src='bower_components/chrome-sync/chrome_sync.js'></script>
<script src='bower_components/honeybadger.js/honeybadger.js'></script>
<script src='bower_components/underscore/underscore-min.js'></script>
<script src='bower_components/jquery/dist/jquery.min.js'></script>
<script src='bower_components/backbone/backbone.js'></script>
<script src='bower_components/mustache/mustache.js'></script>
<script src='bower_components/moment/min/moment-with-locales.min.js'></script>
<script src='scripts/namespace.js'></script>
<script src='scripts/config.js'></script>
<script src='scripts/lib/error_tracker.js'></script>
<script src='scripts/lib/analytics_tracker.js'></script>
<script src='scripts/lib/pagination.js'></script>
<script src='scripts/lib/template.js'></script>
<script src='scripts/chrome/i18n.js'></script>
Expand Down Expand Up @@ -63,9 +62,10 @@
<script src='scripts/presenters/devices_presenter.js'></script>
<script src='scripts/presenters/timeline_presenter.js'></script>
<script src='scripts/presenters/visits_presenter.js'></script>
<script src='scripts/presenters/statistic_presenter.js'></script>
<script src='scripts/presenters/statistic_presenter.js'></script>
<script src='scripts/router.js'></script>
<script src='scripts/initialize_extension.js'></script>
<!-- endbuild -->
</body>
</body>

</html>
5 changes: 1 addition & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"background": {
"scripts": [
"bower_components/honeybadger.js/honeybadger.js",
"bower_components/chrome-sync/chrome_sync.js",
"bower_components/underscore/underscore-min.js",
"scripts/namespace.js",
"scripts/config.js",
"scripts/lib/error_tracker.js",
"scripts/lib/analytics_tracker.js",
"scripts/chrome/page_context_menu.js",
"scripts/chrome/selection_context_menu.js",
"scripts/chrome/omnibox.js",
Expand Down Expand Up @@ -57,5 +54,5 @@
"webRequest",
"webRequestBlocking"
],
"version": "3.9.10.5"
"version": "3.9.11.0"
}
39 changes: 16 additions & 23 deletions scripts/chrome/browser_actions.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
(function() {
var BrowserActions = function(options) {
if(!options.chrome) {
throw("Chrome API not set");
}
if(!options.tracker) {
throw("Tracker not set");
}
var BrowserActions = function(options) {
if (!options.chrome) {
throw ("Chrome API not set");
}

this.chromeAPI = options.chrome;
this.tracker = options.tracker;
};
this.chromeAPI = options.chrome;
};

BrowserActions.prototype.listen = function() {
var _this = this;
if(this.chromeAPI.browserAction) {
this.chromeAPI.browserAction.onClicked.addListener(function() {
_this.openHistory();
});
}
};
BrowserActions.prototype.listen = function() {
var _this = this;
if (this.chromeAPI.browserAction) {
this.chromeAPI.browserAction.onClicked.addListener(
function() { _this.openHistory(); });
}
};

BrowserActions.prototype.openHistory = function() {
this.tracker.browserActionClick();
this.chromeAPI.tabs.create({url: 'chrome://history'});
};
BrowserActions.prototype.openHistory =
function() { this.chromeAPI.tabs.create({url : 'chrome://history'}); };

BH.Chrome.BrowserActions = BrowserActions;
BH.Chrome.BrowserActions = BrowserActions;
})();
72 changes: 30 additions & 42 deletions scripts/chrome/omnibox.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,39 @@
(function() {
var Omnibox = function(options) {
if(!options.chrome) {
throw("Chrome API not set");
}
if(!options.tracker) {
throw("Tracker not set");
}
var Omnibox = function(options) {
if (!options.chrome) {
throw ("Chrome API not set");
}

this.chromeAPI = options.chrome;
this.tracker = options.tracker;
};
this.chromeAPI = options.chrome;
};

Omnibox.prototype.listen = function() {
if(this.chromeAPI.omnibox) {
var _this = this;
this.chromeAPI.omnibox.onInputChanged.addListener(function(text, suggest) {
_this.setDefaultSuggestion(text);
});
Omnibox.prototype.listen = function() {
if (this.chromeAPI.omnibox) {
var _this = this;
this.chromeAPI.omnibox.onInputChanged.addListener(function(
text, suggest) { _this.setDefaultSuggestion(text); });

this.chromeAPI.omnibox.onInputEntered.addListener(function(text) {
_this.tracker.omniboxSearch();
_this.getActiveTab(function(tabId) {
_this.updateTabURL(tabId, text);
});
});
}
};
this.chromeAPI.omnibox.onInputEntered.addListener(function(text) {
_this.getActiveTab(function(tabId) { _this.updateTabURL(tabId, text); });
});
}
};

Omnibox.prototype.setDefaultSuggestion = function(text) {
if(this.chromeAPI.omnibox) {
this.chromeAPI.omnibox.setDefaultSuggestion({
description: "Search <match>" + text + "</match> in history"
});
}
};
Omnibox.prototype.setDefaultSuggestion = function(text) {
if (this.chromeAPI.omnibox) {
this.chromeAPI.omnibox.setDefaultSuggestion(
{description : "Search <match>" + text + "</match> in history"});
}
};

Omnibox.prototype.getActiveTab = function(callback) {
this.chromeAPI.tabs.query({active: true, currentWindow: true}, function(tabs) {
callback(tabs[0].id);
});
};
Omnibox.prototype.getActiveTab = function(callback) {
this.chromeAPI.tabs.query({active : true, currentWindow : true},
function(tabs) { callback(tabs[0].id); });
};

Omnibox.prototype.updateTabURL = function(tabId, text) {
this.chromeAPI.tabs.update(tabId, {
url: "chrome://history/#search/" + text
});
};
Omnibox.prototype.updateTabURL = function(tabId, text) {
this.chromeAPI.tabs.update(tabId, {url : "chrome://history/#search/" + text});
};

BH.Chrome.Omnibox = Omnibox;
BH.Chrome.Omnibox = Omnibox;
})();
183 changes: 88 additions & 95 deletions scripts/chrome/page_context_menu.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,97 @@
(function() {
var getDomain = function(url) {
var match = url.match(/\w+:\/\/(.*?)\//);
if(match) {
return match[1].replace('www.', '');
var getDomain = function(url) {
var match = url.match(/\w+:\/\/(.*?)\//);
if (match) {
return match[1].replace('www.', '');
}
return false;
};

var PageContextMenu = function(options) {
if (!options.chrome) {
throw ("Chrome API not set");
}

this.chromeAPI = options.chrome;

this.id = 'better_history_page_context_menu';
};

PageContextMenu.prototype.create = function() {
this.menu = this.chromeAPI.contextMenus.create({
title : this.chromeAPI.i18n.getMessage('visits_to_domain', [ 'domain' ]),
contexts : [ 'page' ],
id : this.id
});

var _this = this;
this.chromeAPI.contextMenus.onClicked.addListener(function(
data) { _this.onClick(data); });
};

PageContextMenu.prototype.onClick = function(data) {
if (data.menuItemId === this.id) {
var domain = getDomain(data.pageUrl);

url = "chrome://history/#search";
if (domain) {
url += '/' + domain;
}
return false;
};

var PageContextMenu = function(options) {
if(!options.chrome) {
throw("Chrome API not set");
}
if(!options.tracker) {
throw("Tracker not set");
}

this.chromeAPI = options.chrome;
this.tracker = options.tracker;

this.id = 'better_history_page_context_menu';
};

PageContextMenu.prototype.create = function() {
this.menu = this.chromeAPI.contextMenus.create({
title: this.chromeAPI.i18n.getMessage('visits_to_domain', ['domain']),
contexts: ['page'],
id: this.id
});

var _this = this;
this.chromeAPI.contextMenus.onClicked.addListener(function(data) {
_this.onClick(data);
});
};

PageContextMenu.prototype.onClick = function(data) {
if(data.menuItemId === this.id) {
var domain = getDomain(data.pageUrl);

url = "chrome://history/#search";
if(domain) {
url += '/' + domain;
}

this.tracker.contextMenuClick();

this.chromeAPI.tabs.create({url: url});
this.chromeAPI.tabs.create({url : url});
}
};

PageContextMenu.prototype.updateTitleDomain = function(tab) {
if (tab) {
var domain = getDomain(tab.url);
if (domain) {
this.chromeAPI.contextMenus.update(this.menu, {
title : this.chromeAPI.i18n.getMessage('visits_to_domain', [ domain ])
});
}
};

PageContextMenu.prototype.updateTitleDomain = function(tab) {
if(tab) {
var domain = getDomain(tab.url);
if(domain) {
this.chromeAPI.contextMenus.update(this.menu, {
title: this.chromeAPI.i18n.getMessage('visits_to_domain', [domain])
});
}
}
};

PageContextMenu.prototype.listenToTabs = function() {
if(this.chromeAPI.tabs) {
var _this = this;

if(this.chromeAPI.tabs.onActivated) {
this.chromeAPI.tabs.onActivated.addListener(function(tabInfo) {
if(_this.menu) {
_this.onTabSelectionChanged(tabInfo.tabId);
}
});
}

if(this.chromeAPI.tabs.onUpdated) {
this.chromeAPI.tabs.onUpdated.addListener(function(tabId, changedInfo, tab) {
if(_this.menu) {
_this.onTabUpdated(tab);
}
});
}
}
};
}
};

PageContextMenu.prototype.onTabSelectionChanged = function(tabId) {
PageContextMenu.prototype.listenToTabs = function() {
if (this.chromeAPI.tabs) {
var _this = this;
this.chromeAPI.tabs.get(tabId, function(tab) {
_this.updateTitleDomain(tab);
});
};

PageContextMenu.prototype.onTabUpdated = function(tab) {
if(tab && tab.selected) {
this.updateTitleDomain(tab);
}
};

PageContextMenu.prototype.remove = function() {
this.chromeAPI.contextMenus.remove(this.menu);
delete(this.menu);
};
if (this.chromeAPI.tabs.onActivated) {
this.chromeAPI.tabs.onActivated.addListener(function(tabInfo) {
if (_this.menu) {
_this.onTabSelectionChanged(tabInfo.tabId);
}
});
}

BH.Chrome.PageContextMenu = PageContextMenu;
if (this.chromeAPI.tabs.onUpdated) {
this.chromeAPI.tabs.onUpdated.addListener(function(tabId, changedInfo,
tab) {
if (_this.menu) {
_this.onTabUpdated(tab);
}
});
}
}
};

PageContextMenu.prototype.onTabSelectionChanged = function(tabId) {
var _this = this;
this.chromeAPI.tabs.get(tabId,
function(tab) { _this.updateTitleDomain(tab); });
};

PageContextMenu.prototype.onTabUpdated = function(tab) {
if (tab && tab.selected) {
this.updateTitleDomain(tab);
}
};

PageContextMenu.prototype.remove = function() {
this.chromeAPI.contextMenus.remove(this.menu);
delete (this.menu);
};

BH.Chrome.PageContextMenu = PageContextMenu;
})();
Loading

0 comments on commit 8d32896

Please sign in to comment.