From 9c0d2f9b675d8893fd785ab3c73f632563ebdfbf 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 | 13 +++++-------- js/options.js | 4 ++-- options.html | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/js/background.js b/js/background.js index 3f76fac..6d308fc 100644 --- a/js/background.js +++ b/js/background.js @@ -78,7 +78,7 @@ font: 'Inconsolata', fontSize: 'medium', lineNumbers: true, - extBlacklist: '' + languageBlacklist: '' }; const OPTIONS = Object.keys(OPTIONS_DEFAULTS); @@ -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('languageBlacklist').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..105af9b 100644 --- a/js/options.js +++ b/js/options.js @@ -44,8 +44,8 @@ hljs.highlightBlock(codeEl); } }, - extBlacklist: { - selector: '#ext-blacklist', + languageBlacklist: { + selector: '#language-blacklist', value: 'value', decode: id, render: function(value) {} diff --git a/options.html b/options.html index f70c78b..2b9fd6e 100644 --- a/options.html +++ b/options.html @@ -91,8 +91,8 @@

Select your font size

-

Blacklist Extensions

- +

Blacklist Languages

+

Line numbers:

 package main