Skip to content

Instantly share code, notes, and snippets.

@tungd
Created May 15, 2012 06:13
Show Gist options
  • Save tungd/2699516 to your computer and use it in GitHub Desktop.
Save tungd/2699516 to your computer and use it in GitHub Desktop.
Quick view the first link in twitter
// ==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);
@tungd
Copy link
Author

tungd commented May 15, 2012

To install, save this as a file ends with .user.js (i.e. twitter-quickview.user.js) and drag it to Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment