Skip to content

Commit

Permalink
new option to disable extension on specified sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Dezaimasu committed Oct 14, 2018
1 parent 41b9bc0 commit 3fb019c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"settings_exclusions": {
"message": "Classes of elements excluded from scanning (split by spaces):"
},
"settings_domainExclusions": {
"message": "Newer show button on these sites (split by spaces):"
},
"settings_showSaveDialog": {
"message": "Show \"Save as\" dialog:"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"settings_exclusions": {
"message": "CSS классы элементов, которые будут исключены из сканирования (разделены пробелами):"
},
"settings_domainExclusions": {
"message": "Никогда не показывать кнопку на этих сайтах (разделены пробелами):"
},
"settings_showSaveDialog": {
"message": "Показывать окно \"Сохранить как\":"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"settings_exclusions": {
"message": "CSS класи елементів, виключених зі сканування (розділені пробілами):"
},
"settings_domainExclusions": {
"message": "Ніколи не показувати кнопку на цих сайтах (розділені пробілами):"
},
"settings_showSaveDialog": {
"message": "Показувати вікно \"Зберегти як\":"
},
Expand Down
3 changes: 3 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"settings_exclusions": {
"message": "扫描时排除的元素 class(以空格分隔):"
},
"settings_domainExclusions": {
"message": "??? translation required ???"
},
"settings_showSaveDialog": {
"message": "显示“另存为”对话框:"
},
Expand Down
1 change: 1 addition & 0 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ td:first-child {
height: 25px;
}
input#exclusions,
input#domainExclusions,
input.default-path {
width: 400px;
}
Expand Down
9 changes: 7 additions & 2 deletions js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const de_settings = {
showSaveDialog : newValue => de_settings.showSaveDialog = newValue,
forbidDuplicateFiles : newValue => de_settings.forbidDuplicateFiles = newValue,
saveFullSized : newValue => de_settings.saveFullSized = newValue,
domainExclusions : newValue => {
de_settings.domainExcluded = newValue.split(' ').includes(document.location.host);
de_listeners.switch(!de_settings.domainExcluded);
},
},

prepareHotkeysList: function(folders){
Expand Down Expand Up @@ -217,6 +221,8 @@ const de_contentscript = {
downloadsHistory: [],

init: function(){
window.addEventListener('mouseover', de_listeners.mouseoverListener); // asap

this.host = this.getFilteredHost();
this.isSeparateTab = ['image/', 'video/', 'audio/'].includes(document.contentType.substr(0, 6));
this.srcLocation = this.isSeparateTab ? 'baseURI' : 'currentSrc';
Expand Down Expand Up @@ -543,7 +549,7 @@ const de_listeners = {
},

switch: function(turnOn = true){
const functionName = turnOn ? 'addEventListener' : 'removeEventListener';
const functionName = turnOn && !de_settings.domainExcluded ? 'addEventListener' : 'removeEventListener';
window[functionName]('mouseover', de_listeners.mouseoverListener);
window[functionName]('keydown', de_listeners.keydownListener);
window[functionName]('keyup', de_listeners.keyupListener);
Expand Down Expand Up @@ -577,5 +583,4 @@ function xpath(path, contextNode){
return document.evaluate(path, contextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

window.addEventListener('mouseover', de_listeners.mouseoverListener); // asap
de_contentscript.init();
1 change: 1 addition & 0 deletions js/settings-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ const settingsDefault = {
showSaveDialog : false,
forbidDuplicateFiles : true,
saveFullSized : true,
domainExclusions : '',
};
4 changes: 4 additions & 0 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<td><label for="exclusions"><i18n>settings_exclusions</i18n></label></td>
<td><input id="exclusions"></td>
</tr>
<tr>
<td><label for="domainExclusions"><i18n>settings_domainExclusions</i18n></label></td>
<td><input id="domainExclusions"></td>
</tr>
<tr>
<td><label for="showSaveDialog"><i18n>settings_showSaveDialog</i18n></label></td>
<td><input id="showSaveDialog" type="checkbox"></td>
Expand Down

0 comments on commit 3fb019c

Please sign in to comment.