Created
October 2, 2012 11:11
-
-
Save hippietrail/3818240 to your computer and use it in GitHub Desktop.
Adds a place where you can select and copy the question title + link in markdown
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 Hippietrail's Stack Exchange link sharer | |
// @description Adds a place where you can select and copy the question title + link in markdown | |
// @version 0.9 | |
// @namespace hippietrail | |
// @include http://stackoverflow.com/* | |
// @include http://meta.stackoverflow.com/* | |
// @include http://serferfault.com/* | |
// @include http://meta.serferfault.com/* | |
// @include http://superuser.com/* | |
// @include http://meta.superuser.com/* | |
// @include http://stackapps.com/* | |
// @include http://*.stackexchange.com/* | |
// @include http://meta.*.stackexchange.com/* | |
// ==/UserScript== | |
function main() { | |
if ($('.question-page').length) { | |
$('#question-header h1') | |
.append(' '); | |
$('<span>') | |
.attr('id', 'ht-qh-arrow') | |
.text('▶') | |
.css({color: 'gray'}) | |
.appendTo('#question-header h1') | |
.click(function () { | |
$('#ht-qh-code').toggle(); | |
$('#ht-qh-arrow').text( | |
'▶▼'[ +$('#ht-qh-code').is(":visible") ] | |
); | |
}); | |
$('<code>') | |
.attr('id', 'ht-qh-code') | |
.text( '[' + $('#question-header a:first').text() + ']' | |
+ '(' + window.location.href.match(/^(.*\/\/[^/]*\/[^/]*\/\d+)/)[0] + ')') | |
.css({display: 'none'}) | |
.appendTo('#question-header'); | |
} | |
} | |
function addJsNode (func) { | |
var targ = document.getElementsByTagName ('head')[0] || document.body || document.documentElement, | |
scriptNode = document.createElement ('script'); | |
scriptNode.type = "text/javascript"; | |
scriptNode.textContent = '(' + func.toString() + ')()'; | |
targ.appendChild (scriptNode); | |
} | |
addJsNode (main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment