Add blacklist disabling option

This commit is contained in:
Les De Ridder 2016-05-05 12:06:29 +02:00
parent f03bf7b965
commit 1584fe44eb
3 changed files with 23 additions and 12 deletions

View File

@ -35,13 +35,23 @@ chrome.pageAction.onClicked.addListener(function(tab) {
var filename = betterUrl.substr(betterUrl.lastIndexOf("/")); var filename = betterUrl.substr(betterUrl.lastIndexOf("/"));
filename = cleanExtension(filename); filename = cleanExtension(filename);
chrome.storage.sync.get({url: '', tabbehaviour: '', copytoclipboard: false, replacebookmark: false}, function(config) { chrome.storage.sync.get({url: '', tabbehaviour: '', copytoclipboard: false, replacebookmark: false, disableurlblacklist: false}, function(config) {
if(config.url == '') { if(config.url == '') {
alert("Please select a Pomf clone."); alert("Please select a Pomf clone.");
chrome.tabs.create({ url: "options.html" }); chrome.tabs.create({ url: "options.html" });
return; return;
} }
var blackList = ["pomf.", "mixtape.moe", "catgirlsare.sexy", "cocaine.ninja"];
if(!config.disableblacklist) {
for(black of blackList) {
if(url.indexOf(black) != -1) {
return;
}
}
}
var worker = new Worker('worker.js'); var worker = new Worker('worker.js');
worker.onmessage = function(event) { worker.onmessage = function(event) {
var response = JSON.parse(event.data); var response = JSON.parse(event.data);
@ -112,14 +122,6 @@ function isCoolUrl(url) {
var validExtensions = ["jpg", "jpeg", "png", "gif", "webm", "gifv", "mp4", "mp3", "ogg", "opus"]; var validExtensions = ["jpg", "jpeg", "png", "gif", "webm", "gifv", "mp4", "mp3", "ogg", "opus"];
var blackList = ["pomf.", "mixtape.moe", "catgirlsare.sexy", "cocaine.ninja"];
for(black of blackList) {
if(url.indexOf(black) != -1) {
return false;
}
}
return validExtensions.indexOf(extension) != -1; return validExtensions.indexOf(extension) != -1;
} }

View File

@ -39,11 +39,17 @@
<br /> <br />
<br /> <br />
<input type="checkbox" id="disableurlblacklist"> Disable URL blacklist<br />
<br />
<br />
<!-- <!--
TODO: TODO:
* Disable blacklist (checkbox) * Add pixiv support
* Add progress/status messages * Add progress/status messages
* Add imageboard thread archival support * Add imageboard thread archival support
* Add instagram support
* Add booru support * Add booru support
* Add imgur album support * Add imgur album support
* Add gfycat support * Add gfycat support

View File

@ -29,6 +29,7 @@ function saveOptions() {
var tabbehaviour = document.querySelector('input[name="tabbehaviour"]:checked').value; var tabbehaviour = document.querySelector('input[name="tabbehaviour"]:checked').value;
var copytoclipboard = document.getElementById('copytoclipboard').checked; var copytoclipboard = document.getElementById('copytoclipboard').checked;
var replacebookmark = document.getElementById('replacebookmark').checked; var replacebookmark = document.getElementById('replacebookmark').checked;
var disableurlblacklist = document.getElementById('disableurlblacklist').checked;
chrome.storage.sync.set({ chrome.storage.sync.set({
pomfclone: pomfclone, pomfclone: pomfclone,
@ -36,7 +37,8 @@ function saveOptions() {
customUrl: customUrl, customUrl: customUrl,
tabbehaviour: tabbehaviour, tabbehaviour: tabbehaviour,
copytoclipboard: copytoclipboard, copytoclipboard: copytoclipboard,
replacebookmark: replacebookmark replacebookmark: replacebookmark,
disableurlblacklist: disableurlblacklist
}, function() { }, function() {
var status = document.getElementById('status'); var status = document.getElementById('status');
status.textContent = 'Options saved.'; status.textContent = 'Options saved.';
@ -67,6 +69,7 @@ function restoreOptions() {
document.getElementById('copytoclipboard').checked = config.copytoclipboard; document.getElementById('copytoclipboard').checked = config.copytoclipboard;
document.getElementById('replacebookmark').checked = config.replacebookmark; document.getElementById('replacebookmark').checked = config.replacebookmark;
document.getElementById('disableurlblacklist').checked = config.disableurlblacklist;
}); });
document.getElementById('status').textContent = ''; document.getElementById('status').textContent = '';