From ca178bda2cc5e9b77d33432f9cc32d2def688275 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2021 15:30:31 -0800 Subject: [PATCH 1/6] Ignore .DS_Store --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 62c8935..f32e31a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea/ \ No newline at end of file +.idea/ +.DS_Store From c99b356c01c291cda50789749e1fb13939f676e5 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2021 15:33:21 -0800 Subject: [PATCH 2/6] Match new CSS path; add 'custom selector' option --- src/js/keypress.js | 60 ++++++++++++++++++++++++++++------------------ src/js/options.js | 37 +++++++++++++++++++++------- src/options.html | 15 +++++++++--- 3 files changed, 77 insertions(+), 35 deletions(-) diff --git a/src/js/keypress.js b/src/js/keypress.js index 071673c..079a55d 100644 --- a/src/js/keypress.js +++ b/src/js/keypress.js @@ -3,18 +3,20 @@ * * @author Aaron Saray (http://aaronsaray.com) */ + (function(){ /** * The selectors used to find the URL * @type {array} */ - var selectors = [ + var selectors = [ 'div.selectedEntry a.title', // title bar for active entry, collapsed or expanded '.selectedEntry a.visitWebsiteButton', // the button square button on list view '.list-entries .selected a.visitWebsiteButton', // the button square button on list view 'a.visitWebsiteButton', // the floating one for card view - '.entry.selected a.title' // title bar for active entry in React-based collapsed list view - ]; + '.entry.selected a.title', // title bar for active entry in React-based collapsed list view + '.entry--selected .entry__title', // 2021 Block-Element-Modifier class syntax update + ]; /** * Main feedlybackgroundtab constructor @@ -27,17 +29,26 @@ * @private */ var _triggerKeyCode = 59; + var selectorSet = '' /** * Used to create the default key code from local storage * Also modifies the help popup */ this.init = function() { - chrome.storage.sync.get('shortcutKey', function(settings) { - if (settings.shortcutKey) { - _triggerKeyCode = settings.shortcutKey.charCodeAt(0); + selectorSet = selectors.join(); + + chrome.storage.sync.get( + ['shortcutKey', 'selector'], + function(settings) { + if (settings.shortcutKey) { + _triggerKeyCode = settings.shortcutKey.charCodeAt(0); + } + if (settings.selector) { + selectorSet += `,${settings.selector}`; + } } - }); + ); }; /** @@ -46,24 +57,27 @@ * @param e */ this.keyPressHandler = function(e) { + if ( e.keyCode != _triggerKeyCode) { + return + } + var tag = e.target.tagName.toLowerCase(); - if (tag != 'input' && tag != 'textarea') { - if ((!e.altKey && !e.ctrlKey) && e.keyCode == _triggerKeyCode) { - var url; - for (var x in selectors) { - url = document.querySelector(selectors[x]); - if (url) { - break; - } - } - if (url) { - chrome.extension.sendMessage({url: url.href}); - } - else { - console.log("Could not find any selectors from: " + selectors.join()); - } - } + if (tag == 'input' || tag == 'textarea') { + return; + } + + if (e.altKey || e.ctrlKey ) { + return } + + const found = document.querySelector(selectorSet); + + if( !found ) { + console.log("Could not find any selectors from: " + selectorSet); + return; + } + + chrome.extension.sendMessage({url: found.href}); } }; diff --git a/src/js/options.js b/src/js/options.js index 839702b..87752e8 100644 --- a/src/js/options.js +++ b/src/js/options.js @@ -13,13 +13,13 @@ * @todo figure out how to not refer to the querySelector so many times in the code */ function FBT_Options() { - /** * Validation messages */ var _messages = { success: 'Options saved successfully.', - validateFailure: 'Please choose a shortcut key.' + keyValidateFailure: 'Please choose a shortcut key.', + selectorValidateFailure: 'Correct the CSS selector.', }; /** @@ -51,11 +51,12 @@ * @private */ var _restoreOptions = function() { - chrome.storage.sync.get('shortcutKey', function(settings) { + chrome.storage.sync.get(['shortcutKey', 'selector'], function(settings) { if (!settings.shortcutKey) { settings.shortcutKey = _defaultShortcutKey; } document.querySelector('#fbt_shortcutkey').value = settings.shortcutKey; + document.querySelector('#fbt_selector').value = settings.selector ?? ''; }); }; @@ -64,12 +65,22 @@ * @private */ var _validateAndSave = function() { - var key = document.querySelector('#fbt_shortcutkey'); - if (key.value == '') { - _updateStatus(_messages.validateFailure, _messageTypes.failure); + var shortcutKey = document.querySelector('#fbt_shortcutkey'); + if (shortcutKey.value == '') { + _updateStatus(_messages.keyValidateFailure, _messageTypes.failure); return false; } + const cssSelector = document.querySelector('#fbt_selector').value; + if( cssSelector !== '' ) { + try { + document.querySelector(cssSelector); + } catch { + _updateStatus(_messages.selectorValidateFailure, _messageTypes.failure) + return false; + } + } + _save(); }; @@ -80,9 +91,17 @@ */ var _save = function() { var shortcutKey = document.querySelector('#fbt_shortcutkey').value; - chrome.storage.sync.set({'shortcutKey': shortcutKey}, function () { - _updateStatus(_messages.success, _messageTypes.success); - }); + const selector = document.querySelector('#fbt_selector').value; + + chrome.storage.sync.set( + { + shortcutKey, + selector, + }, + function () { + _updateStatus(_messages.success, _messageTypes.success); + } + ); }; /** diff --git a/src/options.html b/src/options.html index e3cc018..095b0e8 100644 --- a/src/options.html +++ b/src/options.html @@ -32,13 +32,18 @@ #fbt_container h1 { margin-top: 0px; } + input.settingvalue { + font-size: 20px; + padding: 3px 5px; + } #fbt_shortcutkey { width: 20px; - padding: 3px 5px; font-weight: bold; - font-size: 20px; text-align: center; } + #fbt_selector { + width:200px; + } #fbt_status { font-weight: bold; border: 1px solid; @@ -65,7 +70,11 @@

FeedlyBackgroundTab Chrome Extension Options

The following settings are used to modify the behavior of this extension. Please click save when you have finished changing your settings.

- + +
+
+ +
From b8977dc2dcac19623368e96b26e8db3cb3a15b12 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2021 15:39:55 -0800 Subject: [PATCH 3/6] Version cycle + update readme --- README.md | 3 +++ src/manifest.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c79a312..3ad51ea 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ This isn't a donation - it's a loan from you to those in need. You get paid bac Changelog --------- +0.14 +* Fix for new CSS classes. Adds 'additional selectors' option to support quick fixes for future Feedly markup changes (@BrianCS) + 0.13 * Fix for another style change. Thanks @hudochenkov diff --git a/src/manifest.json b/src/manifest.json index 4b146b5..e944b8d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "name": "Feedly Background Tab", - "version": "0.13", + "version": "0.14", "manifest_version": 2, "description": "Open Feedly Links in Background Tab using shortcut key", "content_scripts": [ From 8eeaad731fd218a51124c765431babf9dab3a0fc Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2021 15:41:16 -0800 Subject: [PATCH 4/6] Update my handle --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3ad51ea..2f0b7a7 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,16 @@ This isn't a donation - it's a loan from you to those in need. You get paid bac Changelog --------- 0.14 -* Fix for new CSS classes. Adds 'additional selectors' option to support quick fixes for future Feedly markup changes (@BrianCS) +* Fix for new CSS classes. Adds 'additional selectors' option to support quick fixes for future Feedly markup changes (@bbbrrriiiaaannn) 0.13 * Fix for another style change. Thanks @hudochenkov 0.12 -* Fix for React-based layouts. Thanks @BrianCS +* Fix for React-based layouts. Thanks @bbbrrriiiaaannn 0.11 -* Fix for scenarios I hadn't thought of - like non-expanded article. Thanks @BrianCS +* Fix for scenarios I hadn't thought of - like non-expanded article. Thanks @bbbrrriiiaaannn 0.10 * For some instances, the 0.9 fix wasn't working. Did a fallback for a fix that hopefully fixes this issue From 24fbb120330e73fc8912697257851a80252f5a51 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2021 15:59:53 -0800 Subject: [PATCH 5/6] Pick up selector updates from other open PRs --- src/js/keypress.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/keypress.js b/src/js/keypress.js index 079a55d..b248fe0 100644 --- a/src/js/keypress.js +++ b/src/js/keypress.js @@ -12,10 +12,10 @@ var selectors = [ 'div.selectedEntry a.title', // title bar for active entry, collapsed or expanded '.selectedEntry a.visitWebsiteButton', // the button square button on list view - '.list-entries .selected a.visitWebsiteButton', // the button square button on list view + '.list-entries .inlineFrame--selected a.visitWebsiteButton', // the button square button on list view 'a.visitWebsiteButton', // the floating one for card view '.entry.selected a.title', // title bar for active entry in React-based collapsed list view - '.entry--selected .entry__title', // 2021 Block-Element-Modifier class syntax update + '.list-entries .entry--selected .entry__title', // 2021 Block-Element-Modifier class syntax update ]; /** From 3ba5f88f82f71778bf2756227ef372325704419f Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2021 16:01:24 -0800 Subject: [PATCH 6/6] Add all contributors to changelog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f0b7a7..a104517 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This isn't a donation - it's a loan from you to those in need. You get paid bac Changelog --------- 0.14 -* Fix for new CSS classes. Adds 'additional selectors' option to support quick fixes for future Feedly markup changes (@bbbrrriiiaaannn) +* Fix for new CSS classes. Adds 'additional selectors' option to support quick fixes for future Feedly markup changes. Thanks @bbbrrriiiaaannn, @henley-regatta, @hudochenkov! 0.13 * Fix for another style change. Thanks @hudochenkov