Feedly - Open in Background Tab

Open the selected link in another tab

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Feedly - Open in Background Tab
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Open the selected link in another tab
// @author       JackNUMBER
// @match        *://*.feedly.com/*
// @grant        GM_openInTab
// ==/UserScript==
// Based on Aaron Saray's code, with the fix by henley-regatta: https://github.com/aaronsaray/feedlybackgroundtab/blob/2e828c763f9002d04ea9b1f7fdf79f864d86e7ef/src/js/keypress.js

// code '59' is ';'
const _triggerKeyCode = 59;

(function() {
  'use strict';
/*
  const selectors = [
    '.list-entries .entry--selected a.entry__title', // Additional selector for recent Feedly changes
    'div.selectedEntry a.title',                     // title bar for active entry, collapsed or expanded
    '.selectedEntry 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
  ];
*/
  const selectors = [
    '.TitleOnlyLayout--selected a.EntryTitleLink--selected', // title bar for active entry, collapsed (2024-05-01)
    'a.visitWebsiteButton'                                   // the floating one for card view
  ];
  /**
  * Main feedlybackgroundtab constructor
  */
  const FBT = function() {

    /**
    * handler for key press - must be not in textarea or input and must be not altered
    * Then it sends extension request
    * @param e
    */
    this.keyPressHandler = function(e) {
      const tag = e.target.tagName.toLowerCase();
      console.log('tag', e.target);
      if (tag != 'input' && tag != 'textarea') {
        if ((!e.altKey && !e.ctrlKey) && e.keyCode == _triggerKeyCode) {
          let url;
          for (var x in selectors) {
            url = document.querySelector(selectors[x]);
            console.log(url);
            if (url) {
              break;
            }
          }
          if (url) {
            GM_openInTab(url.href);
          } else {
            console.log("Could not find any selectors from: " + selectors.join());
          }
        }
      }
    }
  };

  if (window == top) {
    const fbt = new FBT();
    window.addEventListener('keypress', fbt.keyPressHandler, false);
  }
})();