Skip to content

Commit ba23e9f

Browse files
committed
v0.46.56.7
1 parent 4a5e192 commit ba23e9f

File tree

11 files changed

+167
-21
lines changed

11 files changed

+167
-21
lines changed

_locales/en/messages.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
"description": "Text",
6464
"message": "Text"
6565
},
66+
"customcss": {
67+
"description": "Enter custom CSS code to be applied to all websites (advanced users)",
68+
"message": "Enter custom CSS code to be applied to all websites (advanced users)"
69+
},
6670
"darkbrown": {
6771
"description": "Dark Brown",
6872
"message": "Dark Brown"
@@ -147,6 +151,14 @@
147151
"description": "Hovered",
148152
"message": "Hovered"
149153
},
154+
"importsuccessoptions": {
155+
"description": "Settings imported successfully",
156+
"message": "Settings imported successfully"
157+
},
158+
"importsuccesscond": {
159+
"description": "Settings imported successfully, except the following (unrecognized name): ",
160+
"message": "Settings imported successfully, except the following (unrecognized name): "
161+
},
150162
"invalidcolour": {
151163
"description": "Your colors weren't saved as one or more were invalid. Please revert your colors or re-enter a correct color.",
152164
"message": "Your colors weren't saved as one or more were invalid. Please revert your colors or re-enter a correct color."
@@ -195,6 +207,10 @@
195207
"description": "Paranoid (hide everything)",
196208
"message": "Paranoid (hide everything)"
197209
},
210+
"pastesettings": {
211+
"description": "Paste in settings and try again",
212+
"message": "Paste in settings and try again"
213+
},
198214
"people": {
199215
"description": "People who bought Andrew coffee",
200216
"message": "People who bought Andrew coffee"

_locales/en_GB/messages.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
"description": "Text",
6464
"message": "Text"
6565
},
66+
"customcss": {
67+
"description": "Enter custom CSS code to be applied to all websites (advanced users)",
68+
"message": "Enter custom CSS code to be applied to all websites (advanced users)"
69+
},
6670
"darkbrown": {
6771
"description": "Dark Brown",
6872
"message": "Dark Brown"
@@ -147,6 +151,14 @@
147151
"description": "Hovered",
148152
"message": "Hovered"
149153
},
154+
"importsuccessoptions": {
155+
"description": "Settings imported successfully",
156+
"message": "Settings imported successfully"
157+
},
158+
"importsuccesscond": {
159+
"description": "Settings imported successfully, except the following (unrecognized name): ",
160+
"message": "Settings imported successfully, except the following (unrecognized name): "
161+
},
150162
"invalidcolour": {
151163
"description": "Your colors weren't saved as one or more were invalid. Please revert your colors or re-enter a correct color.",
152164
"message": "Your colours weren't saved as one or more were invalid. Please revert your colours or re-enter a correct colour."
@@ -195,6 +207,10 @@
195207
"description": "Paranoid (hide everything)",
196208
"message": "Paranoid (hide everything)"
197209
},
210+
"pastesettings": {
211+
"description": "Paste in settings and try again",
212+
"message": "Paste in settings and try again"
213+
},
198214
"people": {
199215
"description": "People who bought Andrew coffee",
200216
"message": "People who bought Andrew coffee"

_locales/en_US/messages.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
"description": "Text",
6464
"message": "Text"
6565
},
66+
"customcss": {
67+
"description": "Enter custom CSS code to be applied to all websites (advanced users)",
68+
"message": "Enter custom CSS code to be applied to all websites (advanced users)"
69+
},
6670
"darkbrown": {
6771
"description": "Dark Brown",
6872
"message": "Dark Brown"
@@ -147,6 +151,14 @@
147151
"description": "Hovered",
148152
"message": "Hovered"
149153
},
154+
"importsuccessoptions": {
155+
"description": "Settings imported successfully",
156+
"message": "Settings imported successfully"
157+
},
158+
"importsuccesscond": {
159+
"description": "Settings imported successfully, except the following (unrecognized name): ",
160+
"message": "Settings imported successfully, except the following (unrecognized name): "
161+
},
150162
"invalidcolour": {
151163
"description": "Your colors weren't saved as one or more were invalid. Please revert your colors or re-enter a correct color.",
152164
"message": "Your colors weren't saved as one or more were invalid. Please revert your colors or re-enter a correct color."
@@ -195,6 +207,10 @@
195207
"description": "Paranoid (hide everything)",
196208
"message": "Paranoid (hide everything)"
197209
},
210+
"pastesettings": {
211+
"description": "Paste in settings and try again",
212+
"message": "Paste in settings and try again"
213+
},
198214
"people": {
199215
"description": "People who bought Andrew coffee",
200216
"message": "People who bought Andrew coffee"

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v0.46.56.7 - Monday, July 25, 2016
2+
- Added capability to Import/Export Settings (and even save your settings to a text file)
3+
- Added option to add custom CSS
4+
- Added support for cloaking of <canvas> elements
5+
16
v0.46.56.6 - Tuesday, June 21, 2016
27
- minor fixes and improved YouTube cloaking
38

css/options.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ div#newPagesRow { font-size: 12px; }
1414
div#pageTitle { font-size: 12px; }
1515
a { color: blue; }
1616
input[type=image] { opacity: 0.5; }
17+
#message { z-index: 999; color: #000; margin: 5px; position: fixed; top: 0; left: 0; padding: 5px; font-weight: bold; border: 1px solid #ffcc66; background-color: #ffffcc; }
1718
#main:hover, input[type=image]:hover { opacity: 1; }
1819
#test { width: 411px; height: 188px; background-image: url('../img/option/demo/background.png'); }
19-
.list { width: 250px; max-height: 300px; overflow-y: auto; border: 1px solid #ccc; background-color: #eee; padding: 5px; }
20-
.listentry:hover { background-color: #fff; }
20+
.list, textarea { width: 250px; max-height: 300px; overflow-y: auto; border: 1px solid #ccc; background-color: #eee; padding: 5px; }
21+
textarea { min-height: 100px; font-family: Arial, Sans-Serif; }
22+
#customcss { width: 100%; height: 200px; }
23+
.listentry:hover, #customcss, #settingsimport { background-color: #fff; }
2124
.clear { clear: both; }
2225
.right, #sampleimage { float: right; }
23-
.message { display: none; color: #000; margin-top: 5px; }
2426
.hide { display: none; }
2527
#listMsg { display: none; color: #000; margin-left: 5px; }
2628
#demo_favicon {

js/background.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function setDefaultOptions() {
149149
defaultOptionValue("s_link", "000099");
150150
defaultOptionValue("s_table", "cccccc");
151151
defaultOptionValue("s_text", "000000");
152+
defaultOptionValue("customcss", "");
152153
// fix hotkey shortcut if in old format (if using + as separator instead of space)
153154
if (localStorage["hotkey"].indexOf('+') != -1) {
154155
localStorage["hotkey"] = localStorage["hotkey"].replace(/\+$/, "APLUSA").replace(/\+/g, " ").replace(/APLUSA/, "+");
@@ -319,6 +320,10 @@ function setDPIcon() {
319320
});
320321
});
321322
}
323+
function initLists() {
324+
blackList = JSON.parse(localStorage['blackList']).sort();
325+
whiteList = JSON.parse(localStorage['whiteList']).sort();
326+
}
322327
// ----- Request library to support content script communication
323328
chrome.tabs.onUpdated.addListener(function(tabid, changeinfo, tab) {
324329
if (changeinfo.status == "loading") {
@@ -426,7 +431,7 @@ var requestDispatchTable = {
426431
} else fontface = localStorage["font"];
427432
if (localStorage["global"] == "false") enable = 'true';
428433
else enable = enabled(sender.tab);
429-
sendResponse({enable: enable, sfwmode: localStorage["sfwmode"], font: fontface, fontsize: localStorage["fontsize"], underline: localStorage["showUnderline"], background: localStorage["s_bg"], text: localStorage["s_text"], table: localStorage["s_table"], link: localStorage["s_link"], bold: localStorage["removeBold"], opacity1: localStorage["opacity1"], opacity2: localStorage["opacity2"], collapseimage: localStorage["collapseimage"], maxheight: localStorage["maxheight"], maxwidth: localStorage["maxwidth"]});
434+
sendResponse({enable: enable, sfwmode: localStorage["sfwmode"], font: fontface, fontsize: localStorage["fontsize"], underline: localStorage["showUnderline"], background: localStorage["s_bg"], text: localStorage["s_text"], table: localStorage["s_table"], link: localStorage["s_link"], bold: localStorage["removeBold"], opacity1: localStorage["opacity1"], opacity2: localStorage["opacity2"], collapseimage: localStorage["collapseimage"], maxheight: localStorage["maxheight"], maxwidth: localStorage["maxwidth"], customcss: localStorage["customcss"]});
430435
}
431436
}
432437
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
@@ -440,8 +445,7 @@ chrome.pageAction.onClicked.addListener(function(tab) {
440445
// Execute
441446
setDefaultOptions();
442447
// save blacklist and whitelist in global variable for faster lookups
443-
blackList = JSON.parse(localStorage['blackList']).sort();
444-
whiteList = JSON.parse(localStorage['whiteList']).sort();
448+
initLists();
445449
setDPIcon();
446450
dpContext();
447451
if ((!optionExists("version") || localStorage["version"] != version) && localStorage["showUpdateNotifications"] == 'true') {

js/dp.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var origtitle;
55
var postloaddelay;
66
var dphotkeylistener;
77
var timestamp = Math.round(new Date().getTime()/1000.0);
8-
function addCloak(sfw, f, fsize, u, bg, text, table, link, bold, o1, o2, collapseimage) {
8+
function addCloak(sfw, f, fsize, u, bg, text, table, link, bold, o1, o2, collapseimage, customcss) {
99
// Inject CSS into page
1010
var cssinject = document.createElement("style");
1111
cssinject.setAttribute("__decreased__", "productivity"+timestamp);
@@ -41,15 +41,15 @@ function addCloak(sfw, f, fsize, u, bg, text, table, link, bold, o1, o2, collaps
4141
else magic += 'none !important; }';
4242

4343
if (sfw == 'SFW' || sfw == 'SFW1' || sfw == 'SFW2') {
44-
if (o1 == 0 && collapseimage == 'true') magic += ' iframe, img, input[type=image], path, polygon, picture { display: none !important; }';
45-
else magic += ' iframe, img, input[type=image], path, polygon, picture { opacity: '+o1+' !important; } iframe:hover, img:hover, input[type=image]:hover, path:hover, polygon:hover { opacity: '+o2+' !important; }';
44+
if (o1 == 0 && collapseimage == 'true') magic += ' iframe, img, canvas, input[type=image], path, polygon, picture { display: none !important; }';
45+
else magic += ' iframe, img, canvas, input[type=image], path, polygon, picture { opacity: '+o1+' !important; } iframe:hover, img:hover, input[type=image]:hover, path:hover, polygon:hover { opacity: '+o2+' !important; }';
4646
}
4747
if (sfw == 'SFW') {
4848
if (o1 == 0 && collapseimage == 'true') magic += ' object, embed, param, video, audio { display: none !important; }';
4949
else magic += ' object, embed, param, video, audio { opacity: '+o1+' !important; } object:hover, embed:hover, param:hover, video:hover, audio:hover { opacity: '+o2+' !important; }';
5050
}
5151
if (sfw == 'SFW1') magic += ' object, embed, param, video, audio { display: none !important; opacity: 0 !important; }';
52-
if (sfw == 'Paranoid') magic += ' iframe, img, input[type=image], path, polygon, object, embed, param, video, audio, picture { display: none !important; opacity: 0 !important; }';
52+
if (sfw == 'Paranoid') magic += ' iframe, img, canvas, input[type=image], path, polygon, object, embed, param, video, audio, picture { display: none !important; opacity: 0 !important; }';
5353

5454
magic += ' .dp'+timestamp+'_visible { visibility: visible !important; opacity: 1 !important; }';
5555
magic += ' .dp'+timestamp+'_unbold { font-weight: normal !important }';
@@ -96,6 +96,7 @@ function addCloak(sfw, f, fsize, u, bg, text, table, link, bold, o1, o2, collaps
9696
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; } ';
9797
magic += ' .usertext-edit textarea { border: 1px dotted #' + table + ' !important; } ';
9898
}
99+
if (customcss) magic += customcss.replace(/(?:\r\n|\r|\n)/g, ' ');
99100
removeCss('initialstealth'+timestamp);
100101
if (jQuery("style[__decreased__='productivity"+timestamp+"']").length) {
101102
jQuery("style[__decreased__='productivity"+timestamp+"']").remove();
@@ -139,7 +140,7 @@ function removeCss(name) {
139140
function init() {
140141
chrome.extension.sendRequest({reqtype: "get-settings"}, function(response) {
141142
if (response.enable == "true") {
142-
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);
143+
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, response.customcss);
143144
dpPostLoad(response.maxheight, response.maxwidth, response.sfwmode, response.bold);
144145
jQuery('body').unbind('DOMSubtreeModified.decreasedproductivity'+timestamp);
145146
jQuery('body').bind('DOMSubtreeModified.decreasedproductivity'+timestamp, function() {

js/options.js

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var version = (function () {
1010
var bkg = chrome.extension.getBackgroundPage();
1111
var error = false;
1212
var oldglobalstate = false;
13+
var settingnames = [];
1314
document.addEventListener('DOMContentLoaded', function () {
1415
$("#tabs").tabs();
1516
$("#o1").slider({min: 0, max: 1, step: 0.05, slide: function(event, ui) { $("#opacity1").val(ui.value); opacitytest(); }, stop: function(event, ui) {
@@ -36,7 +37,7 @@ document.addEventListener('DOMContentLoaded', function () {
3637
}
3738
});
3839
$("#enable, #enableToggle, #enableStickiness, #disableFavicons, #hidePageTitles, #showUnderline, #collapseimage, #removeBold, #showContext, #showIcon, #showUpdateNotifications").click(saveOptions);
39-
$("#iconTitle").blur(saveOptions);
40+
$("#iconTitle, #customcss").blur(saveOptions);
4041
$("#s_bg, #s_text, #s_link, #s_table").keyup(updateDemo);
4142
$("#global").click(function() {
4243
saveOptions();
@@ -92,6 +93,9 @@ document.addEventListener('DOMContentLoaded', function () {
9293
$("#s_preset").change(function() {
9394
stylePreset($(this).val());
9495
});
96+
$("#settingsall").click(settingsall);
97+
$("#importsettings").click(settingsImport);
98+
$("#savetxt").click(downloadtxt);
9599
$(".i18_close").click(closeOptions);
96100
});
97101
function keyhandle(keypressed) {
@@ -128,6 +132,12 @@ function saveElement(id) {
128132
function closeOptions() {
129133
window.open('', '_self', '');window.close();
130134
}
135+
function settingsall() {
136+
selectAll('settingsexport');
137+
}
138+
function selectAll(id) {
139+
$("#"+id).select();
140+
}
131141
function i18load() {
132142
$("#title").html("Decreased Productivity v"+version);
133143
$(".i18_default").html(chrome.i18n.getMessage("default"));
@@ -209,6 +219,7 @@ function i18load() {
209219
$(".i18_translators").html(chrome.i18n.getMessage("translators"));
210220
$(".i18_help").html(chrome.i18n.getMessage("help"));
211221
$(".i18_support").html(chrome.i18n.getMessage("support"));
222+
$("#customcssdesc").html(chrome.i18n.getMessage("customcss"));
212223
$(".i18_supportimg").attr({alt: chrome.i18n.getMessage("support"), title: chrome.i18n.getMessage("support")});
213224
}
214225
function loadOptions() {
@@ -261,6 +272,7 @@ function loadOptions() {
261272
$("#customfontrow").hide();
262273
}
263274
}
275+
loadElement("customcss");
264276
listUpdate();
265277
opacitytest();
266278
updateDemo();
@@ -325,6 +337,9 @@ function saveOptions() {
325337
} else {
326338
error = true;
327339
}
340+
$("#customcss").val($("#customcss").val().replace(/\s*<([^>]+)>\s*/ig, ""));
341+
saveElement("customcss");
342+
updateExport();
328343
// Apply new settings
329344
bkg.optionsSaveTrigger(oldglobalstate, localStorage["global"]);
330345
bkg.hotkeyChange();
@@ -372,7 +387,7 @@ function fontsizeValidation() {
372387
}
373388

374389
function notification(msg) {
375-
$('.message').html(msg).stop().fadeIn("slow").delay(2000).fadeOut("slow")
390+
$('#message').html(msg).stop().fadeIn("slow").delay(2000).fadeOut("slow")
376391
}
377392
function truncText(str) {
378393
if (str.length > 16) return str.substr(0, 16)+'...';
@@ -509,6 +524,8 @@ function listUpdate() {
509524
$('#blacklist').html(blacklistCompiled);
510525
$(".domainRemover").unbind('click');
511526
$(".domainRemover").click(function() { domainRemover($(this).attr('rel'));});
527+
bkg.initLists();
528+
updateExport();
512529
}
513530
function listclear(type) {
514531
if (confirm([chrome.i18n.getMessage("removefromwhitelist"),chrome.i18n.getMessage("removefromblacklist")][type]+'?')) {
@@ -537,4 +554,60 @@ function colorPickLoad(id) {
537554
updateDemo();
538555
}
539556
});
557+
}
558+
559+
function downloadtxt() {
560+
var textToWrite = $("#settingsexport").val();
561+
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
562+
var fileNameToSaveAs = "dp-settings-"+new Date().toJSON()+".txt";
563+
var downloadLink = document.createElement("a");
564+
downloadLink.download = fileNameToSaveAs;
565+
downloadLink.innerHTML = "Download File";
566+
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
567+
downloadLink.click();
568+
downloadLink.remove();
569+
}
570+
function updateExport() {
571+
$("#settingsexport").val("");
572+
settingnames = [];
573+
for (var i in localStorage) {
574+
if (i != "version") {
575+
settingnames.push(i);
576+
$("#settingsexport").val($("#settingsexport").val()+i+"|"+localStorage[i].replace(/(?:\r\n|\r|\n)/g, ' ')+"\n");
577+
}
578+
}
579+
$("#settingsexport").val($("#settingsexport").val().slice(0,-1));
580+
}
581+
function settingsImport() {
582+
var error = "";
583+
var settings = $("#settingsimport").val().split("\n");
584+
if ($.trim($("#settingsimport").val()) == "") {
585+
notification(chrome.i18n.getMessage("pastesettings"));
586+
return false;
587+
}
588+
if (settings.length > 0) {
589+
$.each(settings, function(i, v) {
590+
if ($.trim(v) != "") {
591+
var settingentry = $.trim(v).split("|");
592+
if (settingnames.indexOf($.trim(settingentry[0])) != -1) {
593+
if ($.trim(settingentry[0]) == 'whiteList' || $.trim(settingentry[0]) == 'blackList') {
594+
var listarray = $.trim(settingentry[1]).replace(/(\[|\]|")/g,"").split(",");
595+
if ($.trim(settingentry[0]) == 'whiteList' && listarray.toString() != '') localStorage['whiteList'] = JSON.stringify(listarray);
596+
else if ($.trim(settingentry[0]) == 'blackList' && listarray.toString() != '') localStorage['blackList'] = JSON.stringify(listarray);
597+
} else
598+
localStorage[$.trim(settingentry[0])] = $.trim(settingentry[1]);
599+
} else {
600+
error += $.trim(settingentry[0])+", ";
601+
}
602+
}
603+
});
604+
}
605+
loadOptions();
606+
listUpdate();
607+
if (!error) {
608+
notification(chrome.i18n.getMessage("importsuccessoptions"));
609+
$("#settingsimport").val("");
610+
} else {
611+
notification(chrome.i18n.getMessage("importsuccesscond")+error.slice(0, -2));
612+
}
540613
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
},
2828
"permissions": [ "http://*/*", "https://*/*", "contextMenus", "tabs" ],
2929
"update_url": "http://clients2.google.com/service/update2/crx",
30-
"version": "0.46.56.6"
30+
"version": "0.46.56.7"
3131
}

0 commit comments

Comments
 (0)