Feedly - Open entry in background

Adds 'h' as a hotkey to open selected entry in background tab

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Feedly - Open entry in background
// @description    Adds 'h' as a hotkey to open selected entry in background tab 
// @namespace      userscripts.org/users/Lyk
// @author         Lyk
// @include        http://feedly.com/*
// @include        https://feedly.com/*
// @include        http://*.feedly.com/*
// @include        https://*.feedly.com/*
// @grant          GM_openInTab
// @version        1.0.1
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js
// ==/UserScript==


jQuery.noConflict();

(function() {
	var background_key = 72;
		/* 72 is for the 'h'-key
		** you can change this to any key you want (until I include a script command for that :)
		** pick the corresponding number from here: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
		*/
	/*  
	 May add this infuture version

	var orig_button = jQuery('#floatingPageActionCustomize'); //#pageActionLayouts

	var new_button = orig_button.clone();

	// init new button
	new_button.attr('id', 'open-in-background')
	.find('.pageAction')
	.text('Open in background');

	// insert new button
	orig_button.after(new_button);
	*/


	var open_entry = function() {
		var cur = jQuery('.selectedEntry');
		if (cur.length) {
    		console.log("FeedlyOpenEntryInBackgroundTab: GM_openInTab now");
			GM_openInTab(cur.find('a.title').attr('href'), true);		
			return true;
		} else {
			return false;
		}
	};


	//  new_button.click(open_entry);

	// bind key-handler
	jQuery(document).keydown(function(e) {
		if ( e.which == background_key && !(e.altKey || e.ctrlKey || e.metaKey) ) {
			var el = document.activeElement;

			// if in textfield, do nothing
			if (el && (el.tagName.toLowerCase() == 'input' && el.type == 'text' ||
					el.tagName.toLowerCase() == 'textarea')) {
				return true;  
			}
			return !open_entry(); // To supress default behavior of the event
			// Added for those who have "search as I type" features enabled, etc
		}
	});
})();