Skip to content

Commit

Permalink
v0.46.53
Browse files Browse the repository at this point in the history
  • Loading branch information
andryou committed May 5, 2016
1 parent b982664 commit 20e2577
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 155 deletions.
9 changes: 8 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
v0.46.52 - Wednesday, May 4, 2016
v0.46.53 - Thursday, May 5, 2016
- updated core DP cloaking functions so that DP Option setting changes and the Paranoid Hotkey toggle take effect immediately (without temporarily uncloaking and recloaking open tabs)
- optimized number of calls when cloaking a page (from 3 to 1)
- tweaked page favicon cloaking to be instant
- all DP cloaking identifiers now unique on every page load to avoid conflicts/being overwritten
- more reliable "tab stickiness" (if enabled)

v0.46.52.2 - Wednesday, May 4, 2016
- added new Paranoid Hotkey toggle (default: ALT+P) which toggles between Paranoid mode (all images/media hidden) and the Cloaking Level you chose. Like the cloaking toggle, you have full control over what the hotkeys are (the .1 in the version number v0.46.52.1 = a fix so that any change to the Paranoid Hotkey combo is actually saved; .2 = tweaked Paranoid behaviour)
- toolbar icon action now respects DP enabled state
- tweaked hotkey visual display and fixed potential issue
Expand Down
47 changes: 22 additions & 25 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@ function setDefaultOptions() {
chrome.contextMenus.create({"title": chrome.i18n.getMessage("whitelistdomain"), "contexts": ['browser_action','page_action'], "onclick": function(info, tab){
if (tab.url.substring(0, 4) != 'http') return;
domainHandler(extractDomainFromURL(tab.url), 0);
if (localStorage["enable"] == "true") magician('false', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id, 'true');
if (localStorage["enable"] == "true") magician('false', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
}});
chrome.contextMenus.create({"title": chrome.i18n.getMessage("blacklistdomain"), "contexts": ['browser_action','page_action'], "onclick": function(info, tab){
if (tab.url.substring(0, 4) != 'http') return;
domainHandler(extractDomainFromURL(tab.url), 1);
if (localStorage["enable"] == "true") magician('true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id, 'true');
if (localStorage["enable"] == "true") magician('true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
}});
chrome.contextMenus.create({"title": chrome.i18n.getMessage("removelist"), "contexts": ['browser_action','page_action'], "onclick": function(info, tab){
if (tab.url.substring(0, 4) != 'http') return;
domainHandler(extractDomainFromURL(tab.url), 2);
if (localStorage["enable"] == "true") {
if (localStorage['newPages'] == 'Cloak' || localStorage['global'] == 'true') flag = 'true';
else flag = 'false';
magician(flag, localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id, 'true');
magician(flag, localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
}
}});

Expand Down Expand Up @@ -179,18 +179,17 @@ function recursiveCloak(enable, global, showIcon, hideFavicon, hidePageTitle, ti
var dpcloakindex = cloakedTabs.indexOf(windows[i].tabs[x].id);
if (dpcloakindex != -1) cloakedTabs.splice(dpcloakindex, 1);
else cloakedTabs.push(windows[i].tabs[x].id);
magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, windows[i].tabs[x].id, 'false');
magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, windows[i].tabs[x].id);
}
}
}
});
} else {
if (tabId) magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, tabId, 'true');
if (tabId) magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, tabId);
else {
// If no tabId is passed, it means the user changed an option on the Options page and we must go through all of the individual tabs that have cloaking enabled (we're in this section because global is false)
for (var i=cloakedTabs.length-1; i>=0; --i) {
chrome.tabs.executeScript(cloakedTabs[i], {code: "removeCss('productivity')", allFrames: true});
magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, cloakedTabs[i], 'true');
magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, cloakedTabs[i]);
}
}
}
Expand All @@ -207,22 +206,22 @@ function setDPIcon() {
}
});
}
function magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, tabId, tabSpecific) {
function magician(enable, showIcon, hideFavicon, hidePageTitle, titleText, tabId) {
if (enable == 'true') {
chrome.tabs.executeScript(tabId, {code: "init()", allFrames: true});
if (hideFavicon == 'true') chrome.tabs.executeScript(tabId, {code: "faviconblank()", allFrames: true});
if (hidePageTitle == 'true') chrome.tabs.executeScript(tabId, {code: 'replaceTitle("'+titleText+'");titleBind("'+titleText+'");', allFrames: true});
if (hideFavicon == 'true' && hidePageTitle == 'true') chrome.tabs.executeScript(tabId, {code: 'init();faviconblank();replaceTitle("'+titleText+'");titleBind("'+titleText+'");', allFrames: true});
else if (hideFavicon == 'true' && hidePageTitle != 'true') chrome.tabs.executeScript(tabId, {code: "init();faviconblank();titleRestore();", allFrames: true});
else if (hideFavicon != 'true' && hidePageTitle == 'true') chrome.tabs.executeScript(tabId, {code: 'init();faviconrestore();replaceTitle("'+titleText+'");titleBind("'+titleText+'");', allFrames: true});
else if (hideFavicon != 'true' && hidePageTitle != 'true') chrome.tabs.executeScript(tabId, {code: 'init();faviconrestore();titleRestore();', allFrames: true});
} else {
chrome.tabs.executeScript(tabId, {code: "removeCss('productivity')", allFrames: true});
chrome.tabs.executeScript(tabId, {code: "removeCss()", allFrames: true});
}
if (showIcon == 'true') {
if (enable == 'true') {
chrome.pageAction.setIcon({path: "img/addressicon/"+dpicon+".png", tabId: tabId});
chrome.pageAction.setTitle({title: dptitle, tabId: tabId});
} else {
chrome.pageAction.setIcon({path: "img/addressicon/"+dpicon+"-disabled.png", tabId: tabId});
chrome.pageAction.setTitle({title: dptitle, tabId: tabId});
}
chrome.pageAction.setTitle({title: dptitle, tabId: tabId});
chrome.pageAction.show(tabId);
} else chrome.pageAction.hide(tabId);
}
Expand All @@ -244,11 +243,11 @@ function dpHandle(tab) {
if (dpcloakindex != -1) {
if (dpuncloakindex == -1) uncloakedTabs.push(tab.id);
cloakedTabs.splice(dpcloakindex, 1);
recursiveCloak('false', 'false', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
magician('false', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
} else {
if (dpcloakindex == -1) cloakedTabs.push(tab.id);
uncloakedTabs.splice(dpuncloakindex, 1);
recursiveCloak('true', 'false', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
magician('true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tab.id);
}
}
}
Expand All @@ -266,7 +265,7 @@ chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
if (dpcloakindex == -1) cloakedTabs.push(tabid);
// Cloak page if it meets the criteria
if (dpcheck) {
magician(enabled(tab.url), localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tabid, 'true');
magician(enabled(tab.url), localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tabid);
if (dpdomaincheck != 1 && localStorage["global"] == "false") localStorage["enable"] = "true";
}
if (localStorage["showIcon"] == "true") {
Expand All @@ -283,7 +282,7 @@ chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
if (tab.openerTabId) {
if (cloakedTabs.indexOf(tab.openerTabId) != -1 && dpuncloakindex == -1) {
if (dpcloakindex == -1) cloakedTabs.push(tabid);
magician('true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tabid, 'true');
magician('true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], tabid);
}
}
}
Expand All @@ -299,8 +298,10 @@ var requestDispatchTable = {
"get-enabled": function(request, sender, sendResponse) {
var enable;
var dpdomaincheck = domainCheck(extractDomainFromURL(sender.tab.url));
if (enabled(sender.tab.url) == "true" && dpdomaincheck != 0 && (localStorage["global"] == "true" || (localStorage["global"] == "false" && (cloakedTabs.indexOf(sender.tab.id) != -1 || localStorage["newPages"] == "Cloak" || dpdomaincheck == 1)))) enable = 'true';
var dpcloakindex = cloakedTabs.indexOf(sender.tab.id);
if (enabled(sender.tab.url) == "true" && dpdomaincheck != 0 && (localStorage["global"] == "true" || (localStorage["global"] == "false" && (dpcloakindex != -1 || localStorage["newPages"] == "Cloak" || dpdomaincheck == 1)))) enable = 'true';
else enable = 'false';
if (enable == 'true' && dpcloakindex == -1) cloakedTabs.push(sender.tab.id);
sendResponse({enable: enable, background: localStorage["s_bg"], favicon: localStorage["disableFavicons"], hidePageTitles: localStorage["hidePageTitles"], pageTitleText: localStorage["pageTitleText"], enableToggle: localStorage["enableToggle"], hotkey: localStorage["hotkey"], paranoidhotkey: localStorage["paranoidhotkey"]});
},
"toggle": function(request, sender, sendResponse) {
Expand All @@ -315,24 +316,20 @@ var requestDispatchTable = {
localStorage["savedsfwmode"] = localStorage["sfwmode"];
localStorage["sfwmode"] = "Paranoid";
if (localStorage["global"] == "true") {
if (localStorage["enable"] == "true") recursiveCloak('false', 'true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"]);
recursiveCloak('true', 'true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"]);
localStorage["enable"] = "true";
} else {
var dpcloakindex = cloakedTabs.indexOf(sender.tab.id);
var dpuncloakindex = uncloakedTabs.indexOf(sender.tab.id);
if (dpuncloakindex != -1) uncloakedTabs.splice(dpuncloakindex, 1);
if (dpcloakindex == -1) cloakedTabs.push(sender.tab.id);
else magician('false', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], sender.tab.id);
if (cloakedTabs.indexOf(sender.tab.id) == -1) cloakedTabs.push(sender.tab.id);
magician('true', localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"], sender.tab.id);
localStorage["enable"] = "true";
}
return;
} else {
localStorage["sfwmode"] = localStorage["savedsfwmode"];
localStorage["savedsfwmode"] = "";
dpHandle(sender.tab);
}
dpHandle(sender.tab);
},
"get-settings": function(request, sender, sendResponse) {
if (localStorage["font"] == '-Custom-') {
Expand Down
Loading

0 comments on commit 20e2577

Please sign in to comment.