Created
May 15, 2012 06:13
-
-
Save tungd/2699516 to your computer and use it in GitHub Desktop.
Quick view the first link in twitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @match http://twitter.com/* | |
// @match http://www.twitter.com/* | |
// @match https://twitter.com/* | |
// @match https://www.twitter.com/* | |
// ==/UserScript== | |
/*! | |
* Name: Twitter Quick View | |
* URL: http://tungdao.com | |
* Description: Add `v` keyboard shortcut to open the first link in a tweet | |
* License MIT (c) 2012 Tung Dao | |
*/ | |
;(function(doc) { | |
window.addEventListener('load', function() { | |
console.log('Twitter Quick View Initialized!') | |
doc.addEventListener('keydown', function(e) { | |
if (e.keyCode === 86) { | |
try { | |
[].filter.call( | |
doc.querySelector('.hovered-stream-item') | |
.querySelectorAll('.js-tweet-text a') | |
, function(el) { | |
return !el.dataset['screenName'] | |
} | |
)[0].click() | |
} catch (e) {} | |
} | |
}, false) | |
}, false) | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To install, save this as a file ends with .user.js (i.e. twitter-quickview.user.js) and drag it to Chrome.