-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedditFloatingLink.user.js
More file actions
28 lines (25 loc) · 987 Bytes
/
RedditFloatingLink.user.js
File metadata and controls
28 lines (25 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// ==UserScript==
// @name Reddit: Floating Link
// @description Adds a floating link to the Reddit comments page.
// @include http://www.reddit.com/*comments*
// @include https://www.reddit.com/*comments*
// ==/UserScript==
(function()
{
//Find the article URL.
var anchors = document.getElementsByTagName( "a" );
var articleUrl = "";
for( var loop = 0; loop < anchors.length; loop++ ) {
var anchor = anchors[ loop ];
if (anchor.className.lastIndexOf("title")!=-1){
articleUrl = anchor.href;
}
}
//Add the floating div.
floatingDiv = window.document.createElement('div');
floatingDiv.innerHTML = "<a style='background:#CEE3F8;color:#336699;font-weight:bold' href='"+articleUrl+"'>article</a>";
floatingDiv.style.position = "fixed";
floatingDiv.style.left = "135px";
floatingDiv.style.top = "0";
window.document.getElementsByTagName("body")[0].appendChild(floatingDiv);
})();