Skip to content

Commit

Permalink
Fix site whitelisting/blacklisting
Browse files Browse the repository at this point in the history
  • Loading branch information
crittermike committed Oct 5, 2020
1 parent 00a47be commit 1a88703
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/options/options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ export default {
},
methods: {
saveShortcuts: function() {
this.keys.forEach(key => delete key.sidebarOpen);
this.keys.forEach((key) => {
key.sitesArray = key.sites.split('\n')
delete key.sidebarOpen
});
localStorage.shortkeys = JSON.stringify({keys: this.keys});
this.$buefy.snackbar.open(`Shortcuts have been saved!`);
},
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ let globToRegex = function (glob) {
* @returns {boolean}
*/
let isAllowedSite = function (keySetting, url) {
if (keySetting.blacklist !== 'true' && keySetting.blacklist !== 'whitelist') {
if (!keySetting.blacklist || keySetting.blacklist === 'false') {
// This shortcut is allowed on all sites (not blacklisted or whitelisted).
return true
}
let allowed = keySetting.blacklist === 'true'
let allowed = (keySetting.blacklist === true || keySetting.blacklist === 'true')
keySetting.sitesArray.forEach((site) => {
if (url.match(globToRegex(site))) {
allowed = !allowed
Expand Down
1 change: 0 additions & 1 deletion app/scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ Mousetrap.prototype.stopCallback = function (e, element, combo) {
*/
browser.runtime.sendMessage({action: 'getKeys', url: document.URL}).then(function (response) {
if (response) {
console.log(response);
Shortkeys.keys = response
if (Shortkeys.keys.length > 0) {
Shortkeys.keys.forEach((key) => {
Expand Down

0 comments on commit 1a88703

Please sign in to comment.