Created
April 9, 2011 15:04
A simple Greasemonkey script for a dual pane Hacker News interface
This file contains 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== | |
// @name HN Dual Pane | |
// @namespace com.chetansastry | |
// @description An experimental dual pane version of Hacker News | |
// @include http://news.ycombinator.com/* | |
// ==/UserScript== | |
var win = unsafeWindow, | |
isCommentPage = !!win.location.href.match(/item\?/); | |
//Add splitpane | |
document.querySelector('body>center').style.width = '50%'; | |
document.querySelector('body>center>table').width = '90%'; | |
var frame = document.createElement("iframe"); | |
frame.name = 'gm_target'; | |
frame.style.position = 'fixed'; | |
frame.style.width='50%'; | |
frame.style.right=0; | |
frame.style.top=0; | |
frame.style.height='100%'; | |
frame.style.borderStyle='none'; | |
document.body.appendChild(frame); | |
if (!isCommentPage) { | |
//go through each link to articles and update the href target | |
var links = document.querySelectorAll('td.title>a'); | |
for (var i=links.length-1; i>=0 ; i--) { | |
links[i].setAttribute('target', 'gm_target'); | |
} | |
} | |
else { | |
//already on comment page. Load the relevant article in the frame | |
var articleLink = document.querySelector('td.title>a'); | |
frame.src = articleLink.href; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment