forked from rchern/StackExchangeScripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SEModifications.user.js
70 lines (64 loc) · 2.58 KB
/
SEModifications.user.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// ==UserScript==
// @name SE Modifications
// @description A collection of modifications for the Stack Exchange network of sites
// @include http://stackoverflow.com/*
// @include http://meta.stackoverflow.com/*
// @include http://superuser.com/*
// @include http://meta.superuser.com/*
// @include http://serverfault.com/*
// @include http://meta.serverfault.com/*
// @include http://askubuntu.com/*
// @include http://meta.askubuntu.com/*
// @include http://answers.onstartups.com/*
// @include http://meta.answers.onstartups.com/*
// @include http://nothingtoinstall.com/*
// @include http://meta.nothingtoinstall.com/*
// @include http://seasonedadvice.com/*
// @include http://meta.seasonedadvice.com/*
// @include http://stackapps.com/*
// @include http://*.stackexchange.com/*
// @exclude http://chat.stackexchange.com/*
// @exclude http://chat.*.stackexchange.com/*
// @exclude http://api.*.stackexchange.com/*
// @exclude http://odata.stackexchange.com/*
// @exclude http://area51.stackexchange.com/*
// @exclude http://*/reputation
// @author @rchern
// ==/UserScript==
function with_jquery(f) {
var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + f.toString() + ")(jQuery)";
document.body.appendChild(script);
};
with_jquery(function ($) {
$(function () {
// make comment timestamps a link to the comment
$(".comments tr").each(function () {
var commentId = this.id;
var href = "<a href='#" + commentId + "'/>";
$(".comment-date", this).wrap(href);
});
// add timeline and history links to post menu
var questionURL = $("#question-header a").attr("href");
if (questionURL) {
var post = questionURL.replace("questions", "posts").replace(/\/[^\/]*$/, ""),
timeline = post + "/timeline",
revisions = post + "/revisions";
$("#question .post-menu").append("<span class='lsep'>|</span><a href='" + timeline + "'>timeline</a>");
$(".post-menu").each(function() {
if (!revisions)
revisions = "/posts"
+ $(this).find("a:contains('link'):first")
.attr("href")
.replace(questionURL, "")
.replace(/#.*/, "")
+ "/revisions";
$(this).append("<span class='lsep'>|</span><a href='" + revisions + "'>history</a>");
revisions = null;
});
}
// adds an audit link next to your rep in the header that leads to /reputation
$("#hlinks-user .reputation-score").parent().after("<a href='/reputation'>(audit)</a>");
});
});