mirror of
https://github.com/wassname/Mostly-Harmless.git
synced 2026-07-17 01:30:28 +08:00
Privacy settings! Excluded domains and regex patterns.
This commit is contained in:
@@ -163,18 +163,11 @@ this.manifest = {
|
||||
"type": "description",
|
||||
"text": "<p>If this checkbox is selected, Mostly Harmless will not activate unless you click its icon.</p>"
|
||||
},
|
||||
{
|
||||
"tab": "Privacy",
|
||||
"group": "Warning!",
|
||||
"name": "excludedDescription",
|
||||
"type": "description",
|
||||
"text": "<h3>Exclusions do not work yet!</h3><p><big>I am waiting on Fancy Settings to support textareas.</big></p><p>Mostly Harmless grabs data from the Reddit API every time you load a page. This takes time and bandwidth, taxes the reddit API, and sends the unencrypted URL to reddit. However, you can exclude certain domains or URL patterns from being looked up.</p>"
|
||||
},
|
||||
{
|
||||
"tab": "Privacy",
|
||||
"group": "Excluded Domains",
|
||||
"name": "excludedDomains",
|
||||
"type": "text",
|
||||
"type": "textarea",
|
||||
"label": "Excluded domains:",
|
||||
"text": "secure.ingdirect.com\nchaseonline.chase.com\nonline.wellsfargo.com"
|
||||
},
|
||||
@@ -189,7 +182,7 @@ this.manifest = {
|
||||
"tab": "Privacy",
|
||||
"group": "Excluded Regex",
|
||||
"name": "excludedRegex",
|
||||
"type": "text",
|
||||
"type": "textarea",
|
||||
"label": "Excluded regex matches",
|
||||
"text": "chrome:\/\/.*\nhttps?:\/\/www\.google\.com\/search.*\nhttps?:\/\/search\.yahoo\.com\/search.*\nhttps?:\/\/www\.bing\.com\/search.*"
|
||||
},
|
||||
@@ -198,7 +191,7 @@ this.manifest = {
|
||||
"group": "Excluded Regex",
|
||||
"name": "excludedRegexDescription",
|
||||
"type": "description",
|
||||
"text": "<p>Put regular expressions, one per line, in the above text box. Please do not use the <code>\\n</code> character, because there should be no newlines in a URL. Any page that matches the listed regular expressions will <strong>not</strong> activate Mostly Harmless."
|
||||
"text": "<p>Put regular expressions, one per line, in the above text box. Any page that matches the listed regular expressions will <strong>not</strong> activate Mostly Harmless."
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
+20
-6
@@ -8,7 +8,9 @@ settings = new Store('settings', {
|
||||
'shamelessPlug': false,
|
||||
'waitForClick': false,
|
||||
'checkMail': true,
|
||||
'mailInterval': 1
|
||||
'mailInterval': 1,
|
||||
'excludedDomains': 'secure.ingdirect.com\nchaseonline.chase.com\nonline.wellsfargo.com',
|
||||
'excludedRegex': 'chrome://.*\nchrome-extension://.*\nview-source://.*\nftp://.*\nhttps?://www\.google\.com/search.*\nhttps?://search\.yahoo\.com/search.*\nhttps?://www\.bing\.com/search.*\nhttps?://www.reddit.com/(?:r/(?:\w|\+)+/?)?(?:$|\?count)'
|
||||
});
|
||||
cache = new Store('cache');
|
||||
|
||||
@@ -701,9 +703,7 @@ RedditAPI.prototype.submitComment = function (e) {
|
||||
textarea.onkeyup = function () {return true;};
|
||||
url = document.getElementById(fullName).parentNode.getAttribute('data-url');
|
||||
oldCache = cache.get(url);
|
||||
console.log(oldCache);
|
||||
oldCache.posts[fullName].savedCommentText = '';
|
||||
console.log(oldCache);
|
||||
cache.set(url, oldCache);
|
||||
}
|
||||
|
||||
@@ -755,10 +755,25 @@ function Background() {
|
||||
*/
|
||||
Background.prototype.prepareBrowserAction = function (tabId, info, tab) {
|
||||
if (info.status === 'loading') {
|
||||
if (settings.get('waitForClick') === false) {
|
||||
var excludedRegex, match;
|
||||
|
||||
excludedRegex = settings.get('excludedRegex').split('\n');
|
||||
excludedDomains = settings.get('excludedDomains').split('\n');
|
||||
match = false;
|
||||
|
||||
for (var i = 0; i < excludedRegex.length; i++) {
|
||||
if (tab.url.match(new RegExp(excludedRegex[i], "i")) !== null) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.parseURL(tab.url).host in utils.objConvert(excludedDomains)) {
|
||||
match = true;
|
||||
}
|
||||
|
||||
if (settings.get('waitForClick') === false && match === false) {
|
||||
if (cache.get(tab.url) === undefined || cache.get(tab.url).cacheDate - utils.epoch() < -60 * settings.get('cacheTime')) {
|
||||
console.log(chrome.i18n.getMessage('loading_api'));
|
||||
console.log(utils.parseURL(tab.url));
|
||||
reddit.getInfo(tab.url, tabId);
|
||||
} else {
|
||||
console.log(chrome.i18n.getMessage('loading_cache'));
|
||||
@@ -787,7 +802,6 @@ Background.prototype.watchMail = function () {
|
||||
mailInterval = (settings.get('mailInterval') === 0) ? 1000 * 30 : settings.get('mailInterval') * 1000 * 60;
|
||||
|
||||
if (hasMail === true) {
|
||||
console.log('Orangered! I need to show a notification...');
|
||||
notification = webkitNotifications.createNotification(
|
||||
'/pix/mail.png', // icon url - can be relative
|
||||
chrome.i18n.getMessage('orangered_received'), // notification title
|
||||
|
||||
Reference in New Issue
Block a user