From f51e3252b97d7111a363bfbaece9b34a98cb21b9 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Wed, 12 Oct 2016 13:12:56 -0400 Subject: [PATCH] Blacklist languages instead of extensions --- js/background.js | 11 ++++------- js/options.js | 4 ++-- options.html | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/js/background.js b/js/background.js index 3f76fac..cc3eba2 100644 --- a/js/background.js +++ b/js/background.js @@ -122,11 +122,11 @@ return filename.split('.').pop(); } - function isExtensionBlacklisted(extension) { - var blacklist = localStorage.getItem('extBlacklist').split(/[\s,]+/); + function isLanguageBlacklisted(language) { + var blacklist = localStorage.getItem('blacklist-language').split(/[\s,]+/); var index, length = blacklist.length; for (index = 0; index < length; index++) { - if (blacklist[index].toLowerCase() === extension) { + if (blacklist[index].toLowerCase() === language) { return true; } } @@ -142,9 +142,6 @@ if (BROWSER_CONTENT.indexOf(contentType) != -1) { return null; } - if (isExtensionBlacklisted(extension)) { - return null; - } return !!LANG_EXT_MAP[fragment] ? fragment : EXT_LANG_MAP[contentType] || EXT_LANG_MAP[extension] || EXT_LANG_MAP[filename]; @@ -171,7 +168,7 @@ var filename = getFilenameFromUrl(details.url); var extension = getExtensionFromFilename(filename); var language = detectLanguage(contentType, fragment, filename, extension); - if (!language) { + if (!language || isLanguageBlacklisted(language)) { return; } diff --git a/js/options.js b/js/options.js index 060afbd..99d17d1 100644 --- a/js/options.js +++ b/js/options.js @@ -44,8 +44,8 @@ hljs.highlightBlock(codeEl); } }, - extBlacklist: { - selector: '#ext-blacklist', + blacklistLanguages: { + selector: '#blacklist-languages', value: 'value', decode: id, render: function(value) {} diff --git a/options.html b/options.html index f70c78b..b3ed709 100644 --- a/options.html +++ b/options.html @@ -91,8 +91,8 @@

Select your font size

-

Blacklist Extensions

- +

Blacklist Languages

+

Line numbers:

 package main