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("/"));
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 == '') {
alert("Please select a Pomf clone.");
chrome.tabs.create({ url: "options.html" });
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');
worker.onmessage = function(event) {
var response = JSON.parse(event.data);
@ -109,17 +119,9 @@ function isCoolUrl(url) {
var extensionIndex = url.lastIndexOf('.');
var extension = cleanExtension(url.substr(extensionIndex + 1));
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;
}

View File

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

View File

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