Open the selected link in another tab
当前为
// ==UserScript==
// @name Feedly - Open in Background Tab Yo
// @namespace http://tampermonkey.net/
// @version 1.1
// @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
];
/**
* 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();
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]);
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);
}
})();