Last active
May 16, 2025 19:10
-
-
Save Brottweiler/e5210b59ad4a3ffba6c9b6977e5bce70 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 redd.it short link | |
// @homepageURL https://gist.github.com/Brottweiler/e5210b59ad4a3ffba6c9b6977e5bce70 | |
// @downloadURL https://gist.github.com/Brottweiler/e5210b59ad4a3ffba6c9b6977e5bce70/raw/reddit-shortlink.user.js | |
// @namespace Violentmonkey Scripts | |
// @match https://www.reddit.com/r/*/comments/* | |
// @grant none | |
// @version 1.2 | |
// @author Brottweiler | |
// @description Adds a way to get the redd.it short link for new reddit. | |
// @require http://code.jquery.com/jquery-latest.js | |
// ==/UserScript== | |
var config = { | |
copy: true, // copy to clipboard when clicked? | |
alert: true // send an alert when clicked? | |
} | |
$(document).ready(function() { | |
var postId = $(location).attr('href').split('/')[6] | |
$('nav').append('<input id="shortlink" type="text" value="https://redd.it/' + postId + '" style="background-color:#333;color:#999;cursor:pointer;" readonly>') | |
if (config.copy) { | |
$("#shortlink").click(function(){ | |
navigator.clipboard.writeText("https://redd.it/" + postId) | |
if (config.alert) { | |
alert('Copied to clipboard.') | |
} | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment