🏠 Home 

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. // code '59' is ';'
  12. const _triggerKeyCode = 59;
  13. (function() {
  14. 'use strict';
  15. /*
  16. const selectors = [
  17. '.list-entries .entry--selected a.entry__title', // Additional selector for recent Feedly changes
  18. 'div.selectedEntry a.title', // title bar for active entry, collapsed or expanded
  19. '.selectedEntry a.visitWebsiteButton', // the button square button on list view
  20. '.list-entries .inlineFrame--selected a.visitWebsiteButton', // the button square button on list view
  21. 'a.visitWebsiteButton', // the floating one for card view
  22. '.entry.selected a.title' // title bar for active entry in React-based collapsed list view
  23. ];
  24. */
  25. const selectors = [
  26. '.TitleOnlyLayout--selected a.EntryTitleLink--selected', // title bar for active entry, collapsed (2024-05-01)
  27. 'a.visitWebsiteButton' // the floating one for card view
  28. ];
  29. /**
  30. * Main feedlybackgroundtab constructor
  31. */
  32. const FBT = function() {
  33. /**
  34. * handler for key press - must be not in textarea or input and must be not altered
  35. * Then it sends extension request
  36. * @param e
  37. */
  38. this.keyPressHandler = function(e) {
  39. const tag = e.target.tagName.toLowerCase();
  40. console.log('tag', e.target);
  41. if (tag != 'input' && tag != 'textarea') {
  42. if ((!e.altKey && !e.ctrlKey) && e.keyCode == _triggerKeyCode) {
  43. let url;
  44. for (var x in selectors) {
  45. url = document.querySelector(selectors[x]);
  46. console.log(url);
  47. if (url) {
  48. break;
  49. }
  50. }
  51. if (url) {
  52. GM_openInTab(url.href);
  53. } else {
  54. console.log("Could not find any selectors from: " + selectors.join());
  55. }
  56. }
  57. }
  58. }
  59. };
  60. if (window == top) {
  61. const fbt = new FBT();
  62. window.addEventListener('keypress', fbt.keyPressHandler, false);
  63. }
  64. })();