Feedly - Open in Background Tab

Open the selected link in another tab

  1. // ==UserScript==
  2. // @name Feedly - Open in Background Tab
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Open the selected link in another tab
  6. // @author JackNUMBER
  7. // @match *://*.feedly.com/*
  8. // @grant GM_openInTab
  9. // ==/UserScript==
  10. // Based on Aaron Saray's code, with the fix by henley-regatta: https://github.com/aaronsaray/feedlybackgroundtab/blob/2e828c763f9002d04ea9b1f7fdf79f864d86e7ef/src/js/keypress.js
  11.  
  12. // code '59' is ';'
  13. const _triggerKeyCode = 59;
  14.  
  15. (function() {
  16. 'use strict';
  17. /*
  18. const selectors = [
  19. '.list-entries .entry--selected a.entry__title', // Additional selector for recent Feedly changes
  20. 'div.selectedEntry a.title', // title bar for active entry, collapsed or expanded
  21. '.selectedEntry a.visitWebsiteButton', // the button square button on list view
  22. '.list-entries .inlineFrame--selected a.visitWebsiteButton', // the button square button on list view
  23. 'a.visitWebsiteButton', // the floating one for card view
  24. '.entry.selected a.title' // title bar for active entry in React-based collapsed list view
  25. ];
  26. */
  27. const selectors = [
  28. '.TitleOnlyLayout--selected a.EntryTitleLink--selected', // title bar for active entry, collapsed (2024-05-01)
  29. 'a.visitWebsiteButton' // the floating one for card view
  30. ];
  31. /**
  32. * Main feedlybackgroundtab constructor
  33. */
  34. const FBT = function() {
  35.  
  36. /**
  37. * handler for key press - must be not in textarea or input and must be not altered
  38. * Then it sends extension request
  39. * @param e
  40. */
  41. this.keyPressHandler = function(e) {
  42. const tag = e.target.tagName.toLowerCase();
  43. console.log('tag', e.target);
  44. if (tag != 'input' && tag != 'textarea') {
  45. if ((!e.altKey && !e.ctrlKey) && e.keyCode == _triggerKeyCode) {
  46. let url;
  47. for (var x in selectors) {
  48. url = document.querySelector(selectors[x]);
  49. console.log(url);
  50. if (url) {
  51. break;
  52. }
  53. }
  54. if (url) {
  55. GM_openInTab(url.href);
  56. } else {
  57. console.log("Could not find any selectors from: " + selectors.join());
  58. }
  59. }
  60. }
  61. }
  62. };
  63.  
  64. if (window == top) {
  65. const fbt = new FBT();
  66. window.addEventListener('keypress', fbt.keyPressHandler, false);
  67. }
  68. })();