Feedly - Open in Background Tab

Open the selected link in another tab

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
  }
})();