diff --git a/changelog.txt b/changelog.txt index ec1b9b0..cd6a952 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/js/background.js b/js/background.js index 2feb309..d7d343e 100644 --- a/js/background.js +++ b/js/background.js @@ -129,12 +129,12 @@ 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; @@ -142,7 +142,7 @@ chrome.contextMenus.create({"title": chrome.i18n.getMessage("removelist"), "cont 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); } }}); @@ -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]); } } } @@ -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); } @@ -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); } } } @@ -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") { @@ -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); } } } @@ -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) { @@ -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-') { diff --git a/js/dp.js b/js/dp.js index 6d59c25..9ffe7d2 100644 --- a/js/dp.js +++ b/js/dp.js @@ -5,106 +5,110 @@ var origtitle; var postloaddelay; var timestamp = Math.round(new Date().getTime()/1000.0); function addCloak(sfw, f, fsize, u, bg, text, table, link, bold, o1, o2, collapseimage) { - if (!jQuery("style[__decreased__='productivity']").length) { - // Inject CSS into page - var cssinject = document.createElement("style"); - cssinject.setAttribute("__decreased__", "productivity"); - - var curlocation = document.location.href; - var boldcss = ''; - var fontType = ''; - - if (f != 'Serif' && f != 'Monospace' && f != '-Unchanged-') f = '"' + f + '", sans-serif'; - if (f != '-Unchanged-') fontType = 'font-size: ' + fsize + 'px !important; font-family: ' + f + ' !important; h1, h2, h3, h4, h5, h6, h7, h8 { font-size: ' + fsize + 'px !important; font-weight: bold !important; } '; - - if (bold == 'true') boldcss = 'font-weight: normal !important; '; - - // The code that does the magic - var magic = 'html, html *, html *[style], body *:before, body *:after { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; border-collapse: collapse !important; color: #' + text + ' !important; stroke: #' + text + ' !important; fill: #' + bg + ' !important; ' + fontType + 'text-decoration: none !important; -webkit-filter: initial !important; box-shadow: none !important; -webkit-box-shadow: none !important; text-shadow: none !important; ' + boldcss + '} '; - if (curlocation.match(/^https?:\/\/www\.facebook\.com\//i)) { - magic += 'html, html *:not(.img), body *:not(.img):before, body *:not(.img):after { background-image: none !important; } '; - magic += '*:after { content: initial !important; } '; - if (sfw == 'SFW' || sfw == 'SFW1' || sfw == 'SFW2') magic += 'i.img { opacity: '+o1+' !important; } i.img:hover { opacity: '+o2+' !important; } '; - else if (o1 == 0 && collapseimage == 'true') magic += 'i.img { display: none !important; } '; - else if (sfw == 'Paranoid') magic += 'i.img { visibility: hidden !important; opacity: 0 !important; } '; - } else { - magic += 'html, html *, body *:before, body *:after { background-image: none !important; } '; - } - if (curlocation.match(/^https?:\/\/www\.engadget\.com\//i)) { - magic += 'html, html *, html *[style], body *:before, body *:after { border-width: 0px !important; }'; - } else { - magic += 'html, html *, html *[style], body *:before, body *:after { border-width: 1px !important; }'; - } - magic += 'input[type=text],input[type=password],input[type=file],input[type=search],textarea,input[type=button],input[type=submit],#lastpass-notification button[type="button"] { border: 1px dotted #' + table + ' !important; background-color: #' + bg + ' !important; color: #' + text + ' !important; } html::selection, html *::selection { background: #888888 !important; color: #fff !important; } a { color: #' + link + ' !important; text-decoration: '; - - if (u == 'true') magic += 'underline !important; }'; - else magic += 'none !important; }'; - - if (sfw == 'SFW' || sfw == 'SFW1' || sfw == 'SFW2') { - if (o1 == 0 && collapseimage == 'true') magic += ' iframe, img, input[type=image], path, polygon { display: none !important; }'; - else magic += ' iframe, img, input[type=image], path, polygon { opacity: '+o1+' !important; } iframe:hover, img:hover, input[type=image]:hover, path:hover, polygon:hover { opacity: '+o2+' !important; }'; - } - if (sfw == 'SFW') { - if (o1 == 0 && collapseimage == 'true') magic += ' object, embed, param, video, audio { display: none !important; }'; - else magic += ' object, embed, param, video, audio { opacity: '+o1+' !important; } object:hover, embed:hover, param:hover, video:hover, audio:hover { opacity: '+o2+' !important; }'; - } - if (sfw == 'SFW1') magic += ' object, embed, param, video, audio { display: none !important; opacity: 0 !important; }'; - if (sfw == 'Paranoid') magic += ' iframe, img, input[type=image], path, polygon, object, embed, param, video, audio { display: none !important; opacity: 0 !important; }'; - - magic += ' .dp'+timestamp+'_visible { visibility: visible !important; opacity: 1 !important; }'; - magic += ' .dp'+timestamp+'_unbold { font-weight: normal !important }'; - magic += ' .dp'+timestamp+'_link { color: #'+link+' !important; background-color: #'+bg+' !important; background-image: none !important; }'; - magic += ' .dp'+timestamp+'_text { color: #'+text+' !important; background-color: #'+bg+' !important; background-image: none !important; }'; - magic += ' .dp'+timestamp+'_hide { display: none !important }'; - - if (curlocation.match(/^https?:\/\/www\.facebook\.com\//i)) { - magic += " ._52c6, ._5ine, .__cy, .fbPhotosPhotoTagboxes, ._jfi, ._5vb_ ._5aqh::before { position: initial !important; } "; // fix link caption, event cover photo, full-screen photo mode (._jfi = uploaded image thumbnail), instagram - magic += " ._4zoz._4zoz._4zoz, ._559p { clear: both !important; } "; // fix main timeline post status box - } - else if (curlocation.match(/^https?:\/\/www\.instagram\.com\//i)) { - magic += " ._ovg3g, ._njmhc { position: initial !important; } ._sppa1 { display: none !important; } "; - } - else if (curlocation.match(/^https?:\/\/www\.youtube\.com\//i)) { - magic += " .like-button-renderer-like-button:before, .like-button-renderer-dislike-button:before { content: '' !important; } "; - } - else if (curlocation.match(/^https?:\/\/web\.whatsapp\.com\//i)) { - magic += " .message-in { float: none !important; } "; // fix incoming message display - magic += " .msg { clear: both !important; } "; // fix outgoing message display - magic += " .message-meta { position: initial !important; } "; // fix message timestamping - magic += ' .bubble { border: 1px dotted #' + table + ' !important; } '; // distinguish bubbles - magic += ' .drawer-manager, .drawer-manager > .pane { background-color: transparent !important; } '; // fix white screen bug - } - else if (curlocation.match(/^https?:\/\/twitter\.com\//i)) { - magic += " .QuoteTweet, .QuoteTweet *, #playerContainer, #playerContainer * { background-color: transparent !important; } "; - if (sfw != 'Paranoid' && sfw != 'SFW1') magic += " #playerContainer video { opacity: 1 !important; } "; - magic += " .Grid--withGutter>.Grid-cell { margin-right: -1px !important; margin-left: -1px !important; } "; - } - else if (curlocation.match(/^https?:\/\/plus\.google\.com\//i)) { - magic += " .x2 { position: initial !important; } "; - } - else if (curlocation.match(/^https?:\/\/www\.engadget\.com\//i)) { - magic += " .o-hit { cursor: initial !important; } "; - magic += " .o-hit .o-hit__link { position: initial !important; } "; - } - else if (curlocation.match(/^https?:\/\/.*\.?((lifehack|gawk)er|deadspin|jalopnik|gizmodo|jezebel|kotaku)\.com\//i)) { - magic += " .img-border:after { position: initial !important; } "; - } - else if (curlocation.match(/^https?:\/\/www\.reddit\.com\//i)) { - magic += ' .res-nightmode #header-bottom-right { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; } '; - magic += ' .RES-keyNav-activeElement, .RES-keyNav-activeElement .md-container, .res-commentBoxes .comment, .res-commentBoxes .comment .comment, .res-commentBoxes .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment .comment { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; } '; - magic += ' .res-nightmode .link, .res-nightmode .RES-keyNav-activeElement, .res-nightmode .RES-keyNav-activeElement .md-container, .res-nightmode.res-commentBoxes .comment, .res-nightmode.res-commentBoxes .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment .comment { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; } '; - magic += ' .res-nightmode #header-bottom-right a, .res-nightmode a.title, .res-nightmode a.title:visited, .res-nightmode .RES-keyNav-activeElement > .tagline, .res-nightmode .RES-keyNav-activeElement .md-container > .md, .res-nightmode .RES-keyNav-activeElement .md-container > .md p, .res-nightmode #search input[type="text"] { color: #' + text + ' !important; } '; - magic += ' .usertext-edit textarea { border: 1px dotted #' + table + ' !important; } '; - } - cssinject.innerText = magic; - document.documentElement.appendChild(cssinject, null); + // Inject CSS into page + var cssinject = document.createElement("style"); + cssinject.setAttribute("__decreased__", "productivity"+timestamp); + + var curlocation = document.location.href; + var boldcss = ''; + var fontType = ''; + + if (f != 'Serif' && f != 'Monospace' && f != '-Unchanged-') f = '"' + f + '", sans-serif'; + if (f != '-Unchanged-') fontType = 'font-size: ' + fsize + 'px !important; font-family: ' + f + ' !important; h1, h2, h3, h4, h5, h6, h7, h8 { font-size: ' + fsize + 'px !important; font-weight: bold !important; } '; + + if (bold == 'true') boldcss = 'font-weight: normal !important; '; + + // The code that does the magic + var magic = 'html, html *, html *[style], body *:before, body *:after { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; border-collapse: collapse !important; color: #' + text + ' !important; stroke: #' + text + ' !important; fill: #' + bg + ' !important; ' + fontType + 'text-decoration: none !important; -webkit-filter: initial !important; box-shadow: none !important; -webkit-box-shadow: none !important; text-shadow: none !important; ' + boldcss + '} '; + if (curlocation.match(/^https?:\/\/www\.facebook\.com\//i)) { + magic += 'html, html *:not(.img), body *:not(.img):before, body *:not(.img):after { background-image: none !important; } '; + magic += '*:after { content: initial !important; } '; + if (sfw == 'SFW' || sfw == 'SFW1' || sfw == 'SFW2') magic += 'i.img { opacity: '+o1+' !important; } i.img:hover { opacity: '+o2+' !important; } '; + else if (o1 == 0 && collapseimage == 'true') magic += 'i.img { display: none !important; } '; + else if (sfw == 'Paranoid') magic += 'i.img { visibility: hidden !important; opacity: 0 !important; } '; + } else { + magic += 'html, html *, body *:before, body *:after { background-image: none !important; } '; + } + if (curlocation.match(/^https?:\/\/www\.engadget\.com\//i)) { + magic += 'html, html *, html *[style], body *:before, body *:after { border-width: 0px !important; }'; + } else { + magic += 'html, html *, html *[style], body *:before, body *:after { border-width: 1px !important; }'; + } + magic += 'input[type=text],input[type=password],input[type=file],input[type=search],textarea,input[type=button],input[type=submit],#lastpass-notification button[type="button"] { border: 1px dotted #' + table + ' !important; background-color: #' + bg + ' !important; color: #' + text + ' !important; } html::selection, html *::selection { background: #888888 !important; color: #fff !important; } a { color: #' + link + ' !important; text-decoration: '; + + if (u == 'true') magic += 'underline !important; }'; + else magic += 'none !important; }'; + + if (sfw == 'SFW' || sfw == 'SFW1' || sfw == 'SFW2') { + if (o1 == 0 && collapseimage == 'true') magic += ' iframe, img, input[type=image], path, polygon { display: none !important; }'; + else magic += ' iframe, img, input[type=image], path, polygon { opacity: '+o1+' !important; } iframe:hover, img:hover, input[type=image]:hover, path:hover, polygon:hover { opacity: '+o2+' !important; }'; } - removeCss('initialstealth'); + if (sfw == 'SFW') { + if (o1 == 0 && collapseimage == 'true') magic += ' object, embed, param, video, audio { display: none !important; }'; + else magic += ' object, embed, param, video, audio { opacity: '+o1+' !important; } object:hover, embed:hover, param:hover, video:hover, audio:hover { opacity: '+o2+' !important; }'; + } + if (sfw == 'SFW1') magic += ' object, embed, param, video, audio { display: none !important; opacity: 0 !important; }'; + if (sfw == 'Paranoid') magic += ' iframe, img, input[type=image], path, polygon, object, embed, param, video, audio { display: none !important; opacity: 0 !important; }'; + + magic += ' .dp'+timestamp+'_visible { visibility: visible !important; opacity: 1 !important; }'; + magic += ' .dp'+timestamp+'_unbold { font-weight: normal !important }'; + magic += ' .dp'+timestamp+'_link { color: #'+link+' !important; background-color: #'+bg+' !important; background-image: none !important; }'; + magic += ' .dp'+timestamp+'_text { color: #'+text+' !important; background-color: #'+bg+' !important; background-image: none !important; }'; + magic += ' .dp'+timestamp+'_hide { display: none !important }'; + + if (curlocation.match(/^https?:\/\/www\.facebook\.com\//i)) { + magic += " ._52c6, ._5ine, .__cy, .fbPhotosPhotoTagboxes, ._jfi, ._5vb_ ._5aqh::before { position: initial !important; } "; // fix link caption, event cover photo, full-screen photo mode (._jfi = uploaded image thumbnail), instagram + magic += " ._4zoz._4zoz._4zoz, ._559p { clear: both !important; } "; // fix main timeline post status box + } + else if (curlocation.match(/^https?:\/\/www\.instagram\.com\//i)) { + magic += " ._ovg3g, ._njmhc { position: initial !important; } ._sppa1 { display: none !important; } "; + } + else if (curlocation.match(/^https?:\/\/www\.youtube\.com\//i)) { + magic += " .like-button-renderer-like-button:before, .like-button-renderer-dislike-button:before { content: '' !important; } "; + } + else if (curlocation.match(/^https?:\/\/web\.whatsapp\.com\//i)) { + magic += " .message-in { float: none !important; } "; // fix incoming message display + magic += " .msg { clear: both !important; } "; // fix outgoing message display + magic += " .message-meta { position: initial !important; } "; // fix message timestamping + magic += ' .bubble { border: 1px dotted #' + table + ' !important; } '; // distinguish bubbles + magic += ' .drawer-manager, .drawer-manager > .pane { background-color: transparent !important; } '; // fix white screen bug + } + else if (curlocation.match(/^https?:\/\/twitter\.com\//i)) { + magic += " .QuoteTweet, .QuoteTweet *, #playerContainer, #playerContainer * { background-color: transparent !important; } "; + if (sfw != 'Paranoid' && sfw != 'SFW1') magic += " #playerContainer video { opacity: 1 !important; } "; + magic += " .Grid--withGutter>.Grid-cell { margin-right: -1px !important; margin-left: -1px !important; } "; + } + else if (curlocation.match(/^https?:\/\/plus\.google\.com\//i)) { + magic += " .x2 { position: initial !important; } "; + } + else if (curlocation.match(/^https?:\/\/www\.engadget\.com\//i)) { + magic += " .o-hit { cursor: initial !important; } "; + magic += " .o-hit .o-hit__link { position: initial !important; } "; + } + else if (curlocation.match(/^https?:\/\/.*\.?((lifehack|gawk)er|deadspin|jalopnik|gizmodo|jezebel|kotaku)\.com\//i)) { + magic += " .img-border:after { position: initial !important; } "; + } + else if (curlocation.match(/^https?:\/\/www\.reddit\.com\//i)) { + magic += ' .res-nightmode #header-bottom-right { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; } '; + magic += ' .RES-keyNav-activeElement, .RES-keyNav-activeElement .md-container, .res-commentBoxes .comment, .res-commentBoxes .comment .comment, .res-commentBoxes .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment, .res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment .comment { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; } '; + magic += ' .res-nightmode .link, .res-nightmode .RES-keyNav-activeElement, .res-nightmode .RES-keyNav-activeElement .md-container, .res-nightmode.res-commentBoxes .comment, .res-nightmode.res-commentBoxes .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment, .res-nightmode.res-commentBoxes .comment .comment .comment .comment .comment .comment .comment .comment .comment .comment { background-color: #' + bg + ' !important; border-color: #' + table + ' !important; } '; + magic += ' .res-nightmode #header-bottom-right a, .res-nightmode a.title, .res-nightmode a.title:visited, .res-nightmode .RES-keyNav-activeElement > .tagline, .res-nightmode .RES-keyNav-activeElement .md-container > .md, .res-nightmode .RES-keyNav-activeElement .md-container > .md p, .res-nightmode #search input[type="text"] { color: #' + text + ' !important; } '; + magic += ' .usertext-edit textarea { border: 1px dotted #' + table + ' !important; } '; + } + removeCss('initialstealth'+timestamp); + if (jQuery("style[__decreased__='productivity"+timestamp+"']").length) { + jQuery("style[__decreased__='productivity"+timestamp+"']").remove(); + jQuery("[__decreased__]").each(function() { + jQuery(this).removeClass('dp'+timestamp+'_visible dp'+timestamp+'_unbold dp'+timestamp+'_link dp'+timestamp+'_text dp'+timestamp+'_hide').removeAttr("__decreased__"); + }); + } + cssinject.innerText = magic; + document.documentElement.appendChild(cssinject, null); } function dpPostLoad(dpheight, dpwidth, sfwmode, bold) { if (dpwidth > 0 && dpheight > 0) { - jQuery("img:not([__decreased__='image'])").each(function() { - jQuery(this).attr('__decreased__', 'image'); + jQuery("img:not([__decreased__='image"+timestamp+"'])").each(function() { + jQuery(this).attr('__decreased__', 'image'+timestamp); if (this.width <= dpwidth && this.height <= dpheight) jQuery(this).addClass('dp'+timestamp+'_visible'); else @@ -112,20 +116,20 @@ function dpPostLoad(dpheight, dpwidth, sfwmode, bold) { }); } if (bold == 'true') { - jQuery("a:not([__decreased__='link'])").addClass('dp'+timestamp+'_link dp'+timestamp+'_unbold').attr('__decreased__', 'link'); - jQuery("body *:not([__decreased__])").addClass('dp'+timestamp+'_text dp'+timestamp+'_unbold').attr('__decreased__', 'element'); + jQuery("a:not([__decreased__='link"+timestamp+"'])").addClass('dp'+timestamp+'_link dp'+timestamp+'_unbold').attr('__decreased__', 'link'+timestamp); + jQuery("body *:not([__decreased__])").addClass('dp'+timestamp+'_text dp'+timestamp+'_unbold').attr('__decreased__', 'element'+timestamp); } else { - jQuery("a:not([__decreased__='link'])").addClass('dp'+timestamp+'_link').attr('__decreased__', 'link'); - jQuery("body *:not([__decreased__])").addClass('dp'+timestamp+'_text').attr('__decreased__', 'element'); + jQuery("a:not([__decreased__='link"+timestamp+"'])").addClass('dp'+timestamp+'_link').attr('__decreased__', 'link'+timestamp); + jQuery("body *:not([__decreased__])").addClass('dp'+timestamp+'_text').attr('__decreased__', 'element'+timestamp); } } function removeCss(name) { + if (typeof(name) === 'undefined') name = "productivity"+timestamp; jQuery("style[__decreased__='"+name+"']").remove(); - if (name == 'productivity') { + if (typeof(name) === 'undefined') { faviconrestore(); - jQuery('title').unbind('DOMSubtreeModified.decreasedproductivity'); - jQuery('body').unbind('DOMSubtreeModified.decreasedproductivity'); - if (origtitle) document.title = origtitle; + titleRestore(); + jQuery('body').unbind('DOMSubtreeModified.decreasedproductivity'+timestamp); jQuery("[__decreased__]").each(function() { jQuery(this).removeClass('dp'+timestamp+'_visible dp'+timestamp+'_unbold dp'+timestamp+'_link dp'+timestamp+'_text dp'+timestamp+'_hide').removeAttr("__decreased__"); }); @@ -136,8 +140,8 @@ function init() { if (response.enable == "true") { addCloak(response.sfwmode, response.font, response.fontsize, response.underline, response.background, response.text, response.table, response.link, response.bold, response.opacity1, response.opacity2, response.collapseimage); dpPostLoad(response.maxheight, response.maxwidth, response.sfwmode, response.bold); - jQuery('body').unbind('DOMSubtreeModified.decreasedproductivity'); - jQuery('body').bind('DOMSubtreeModified.decreasedproductivity', function() { + jQuery('body').unbind('DOMSubtreeModified.decreasedproductivity'+timestamp); + jQuery('body').bind('DOMSubtreeModified.decreasedproductivity'+timestamp, function() { clearTimeout(postloaddelay); postloaddelay = setTimeout(function(){ dpPostLoad(response.maxheight, response.maxwidth, response.sfwmode, response.bold) }, 500); }); @@ -148,13 +152,17 @@ function init() { // Copyright (c) 2006 Michael Mahemoff // Modifications - Andrew Y. function faviconblank() { - var link = document.createElement("link"); - link.type = "image/x-icon"; - link.rel = "shortcut icon"; - link.id = "decreasedproductivity"+timestamp; - link.href = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oFFAADATTAuQQAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQ4y2NgGAWjYBSMAggAAAQQAAGFP6pyAAAAAElFTkSuQmCC'; // transparent png - faviconclear(); - document.getElementsByTagName("head")[0].appendChild(link); + jQuery(document).ready(function() { + if (!jQuery("link#decreasedproductivity"+timestamp).length) { + var link = document.createElement("link"); + link.type = "image/x-icon"; + link.rel = "shortcut icon"; + link.id = "decreasedproductivity"+timestamp; + link.href = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oFFAADATTAuQQAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQ4y2NgGAWjYBSMAggAAAQQAAGFP6pyAAAAAElFTkSuQmCC'; // transparent png + faviconclear(); + document.getElementsByTagName("head")[0].appendChild(link); + } + }); } function faviconclear() { jQuery("link[rel='shortcut icon'], link[rel='icon']").each(function() { @@ -163,7 +171,7 @@ function faviconclear() { } function faviconrestore() { jQuery("link#decreasedproductivity"+timestamp).remove(); - jQuery("link[data-rel='shortcut icon'], link[data-rel='icon']").each(function() { + jQuery("link:not(.intro)[data-rel='shortcut icon'], link[data-rel='icon']").each(function() { jQuery(this).attr('rel', jQuery(this).attr('data-rel')).removeAttr('data-rel'); }); } @@ -175,16 +183,14 @@ function replaceTitle(text) { } } function titleBind(text) { - jQuery('title').unbind('DOMSubtreeModified.decreasedproductivity'); - jQuery('title').bind('DOMSubtreeModified.decreasedproductivity', function() { + jQuery('title').unbind('DOMSubtreeModified.decreasedproductivity'+timestamp); + jQuery('title').bind('DOMSubtreeModified.decreasedproductivity'+timestamp, function() { replaceTitle(text); }); } -function blankPage(bg) { - var stealth = document.createElement("style"); - stealth.setAttribute("__decreased__", "initialstealth"); - stealth.innerText += "html, html *, html *[style], body *:before, body *:after { background-color: #" + bg + " !important; background-image: none !important; background: #" + bg+ " !important; } html * { visibility: hidden !important; }"; - document.documentElement.appendChild(stealth, null); +function titleRestore() { + jQuery('title').unbind('DOMSubtreeModified.decreasedproductivity'+timestamp); + if (origtitle) document.title = origtitle; } // Initially hide all elements on page (injected code is removed when page is loaded) chrome.extension.sendRequest({reqtype: "get-enabled"}, function(response) { @@ -209,7 +215,10 @@ chrome.extension.sendRequest({reqtype: "get-enabled"}, function(response) { replaceTitle(response.pageTitleText); titleBind(response.pageTitleText); } - blankPage(response.background); + var stealth = document.createElement("style"); + stealth.setAttribute("__decreased__", "initialstealth"+timestamp); + stealth.innerText += "html, html *, html *[style], body *:before, body *:after { background-color: #" + response.background + " !important; background-image: none !important; background: #" + response.background+ " !important; } html * { visibility: hidden !important; }"; + document.documentElement.appendChild(stealth, null); init(); } }); \ No newline at end of file diff --git a/js/options.js b/js/options.js index 994c145..abc9a35 100644 --- a/js/options.js +++ b/js/options.js @@ -325,7 +325,7 @@ function saveOptions() { error = true; } // Apply new settings - bkg.recursiveCloak(localStorage["enable"], localStorage["global"], localStorage["showIcon"]); + bkg.recursiveCloak(localStorage["enable"], localStorage["global"], localStorage["showIcon"], localStorage["disableFavicons"], localStorage["hidePageTitles"], localStorage["pageTitleText"]); // Remove any existing styling if (!error) notification(chrome.i18n.getMessage("saved")); else notification(chrome.i18n.getMessage("invalidcolour")); diff --git a/manifest.json b/manifest.json index 200c6c0..fca9cdb 100644 --- a/manifest.json +++ b/manifest.json @@ -27,5 +27,5 @@ }, "permissions": [ "http://*/*", "https://*/*", "contextMenus", "tabs" ], "update_url": "http://clients2.google.com/service/update2/crx", - "version": "0.46.52.2" + "version": "0.46.53" } diff --git a/options.html b/options.html index 6cd49c5..691e85d 100644 --- a/options.html +++ b/options.html @@ -235,7 +235,7 @@

Page Title

Support Andrew!

- People who bought Andrew coffee: Leonardo C., 朱之灏, Donald D., John B., Patrick H., Luke C., Eric G., Brian B., Daniel C., Joel D., Joseph W., David M., Rafal W., Ip L., Caillin P., Simon B., Keith T., Peter C., Gordon M., James M., Ranjan S., Philipp B., Rommel G., Todd A., Jason T., Vineet W., Adam C., Jim M., Alex U., Stanislav S., George T., Genere S., Kevin S., Jérémy P., Carlos S., Miguel L., Adrian H., Scott B., Daniel C., Mark M., Timothy D., Alexis B., Peter C., Christiaan E., Matthew L., Russell H., David D., Keith S., Elena G., Rafael V., Scott F., Paul M., Danielle F., 曾 信夫, Jon T., Barry D., Andrew H., Ma X., Frank E., Alex W., Roger S., Artem S., Wassim N., Rajat N., Vadim P., Celia D., Mikyas W., Reann M., Gabriel J., Anthony Z., Kai Cheong W., Jason T., Michael L., Maximilian B., Anton C., Koen de W., Juan de Dios Egido A.
+ People who bought Andrew coffee: Leonardo C., 朱之灏, Donald D., John B., Patrick H., Luke C., Eric G., Brian B., Daniel C., Joel D., Joseph W., David M., Rafal W., Ip L., Caillin P., Simon B., Keith T., Peter C., Gordon M., James M., Ranjan S., Philipp B., Rommel G., Todd A., Jason T., Vineet W., Adam C., Jim M., Alex U., Stanislav S., George T., Genere S., Kevin S., Jérémy P., Carlos S., Miguel L., Adrian H., Scott B., Daniel C., Mark M., Timothy D., Alexis B., Peter C., Christiaan E., Matthew L., Russell H., David D., Keith S., Elena G., Rafael V., Scott F., Paul M., Danielle F., 曾 信夫, Jon T., Barry D., Andrew H., Ma X., Frank E., Alex W., Roger S., Artem S., Wassim N., Rajat N., Vadim P., Celia D., Mikyas W., Reann M., Gabriel J., Anthony Z., Kai Cheong W., Jason T., Michael L., Maximilian B., Anton C., Koen de W., Juan de Dios Egido A., Harry P.
People who helped translate: Christoph (Deutsch), Luciano (Español), Yamaji (Japanese), Jérémy (Français), VeryFriend (Russian), Lorenzo (Italian)
If you can help translate or improve, please contact me: andryou@gmail.com

Follow me (@andryou) on Twitter!

diff --git a/updated.html b/updated.html index 0b8605f..7eefaab 100644 --- a/updated.html +++ b/updated.html @@ -7,13 +7,22 @@ Decreased Productivity by Andrew Y.

-

Updated to v0.46.52.2! (Wednesday, May 4, 2016)

+

Updated to v0.46.53! (Thursday, May 5, 2016)