[Userscript] Forum post/comment source link generator

DanielTepesKraus
Greatest Poster in the Board -
GREEN - TALK TO ME
Roseluck - Had their OC in the 2023 Derpibooru Collab.
Elements of Harmony - Had an OC in the 2022 Community Collab
Twinkling Balloon - Took part in the 2021 community collab.
Friendship, Art, and Magic (2020) - Took part in the 2020 Community Collab
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Friendship, Art, and Magic (2019) - Celebrated Derpibooru's seventh year anniversary with friends
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)

will return
Description  
As you all know the site dynamically replaces all images posted with the !! syntax with a “camo” link:
 
"!http://i.imgur.com/e99AGEO.gif!"  
becomes  
"!https://camo.derpicdn.net/e549ac47bf33f9a2184243a303fdd1ff28382018?url=http\%3A\%2F\%2Fi.imgur.com\%2Fe99AGEO.gif!"
 
…once it has been posted. While this is a necessary security feature designed to protect the site and your computer from the little gremlins on the web, let’s be honest, it’s also annoying as hell because it makes getting the source of images a pain since you can’t just right-click and copy the source anymore:  
full
 
This script adds a simple “[Image Source]” link beneath every single image posted using the !! syntax, which can be clicked on or source-copied for the pure, unchanged image link.
 
…Which raises the question why doesn’t this outright replace the camo link? Firstly, while it is possible it is rather buggy and will cause security certificate errors on the site. Secondly, the camo links do serve an important purpose which far outweighs the “they are somewhat annoying” aspect.
 
New feature! Now if someone uses the !! syntax to link an image from the ‘Booru itself, this script will also add a “[Derpibooru Post]” link that will take you to the corresponding page.
 
It In Action:  
full  
full
 
Changelog  
V1.1 - 2016/09/18 - Fixed a minor bug that stopped it from running on some domains  
V1.0 – 2016/03/30 – Initial release  
V2.0 - 2017/07/19 - Complete revamp. Now works consistently on image threads  
V2.1 - 2017/07/19 - Bugfix  
V2.2 - 2017/07/28 - Now works with pagination, descriptions, and about me boxes  
V3.0 - 2017/07/29 - Bugfix, now links to Derpibooru images linked with !! syntax
 
Download Link  
Download
 
Disclaimer and Such  
Use at your own risk. This script does not store or access any user data. This script has been tested but may not be entirely bug free. One user has reported that, on occasion, the links may not appear or might appear twice per image, but I’ve not been able to replicate this bug myself and thus find the cause of it.
DanielTepesKraus
Greatest Poster in the Board -
GREEN - TALK TO ME
Roseluck - Had their OC in the 2023 Derpibooru Collab.
Elements of Harmony - Had an OC in the 2022 Community Collab
Twinkling Balloon - Took part in the 2021 community collab.
Friendship, Art, and Magic (2020) - Took part in the 2020 Community Collab
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Friendship, Art, and Magic (2019) - Celebrated Derpibooru's seventh year anniversary with friends
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)

will return
@SuperSupermario24  
no prob. all i did was you need to specify which domains a script will work on. i derped and forgot to specify for it to work on domains that didn’t have www in the title. so it worked, it just wasn’t activating.
Marker
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Magnificent Metadata Maniac - #1 Assistant
Not a Llama - Happy April Fools Day!

Misanthrope
Nice! This is hella useful, I’m definitely keeping this for future use.
 
Though I do have some feedbacks:  
I noticed that the script does not work when navigating between paginated comments or when previewing a parent comment. To fix that, I recommend that instead of using a timer to check for when the comments are loaded, you could use the node-creation-observer library, with which you could register a callback to be fired whenever a specified element is created.  
And with how you structured your code, you could easily straight up replace  
function findComments()  
with  
NodeCreationObserver.onCreation('.communication__body__text', addSourceLinks);  
and that should save you a lot of hassles of dealing with the MutationObserver API yourself.
 
Additionally, you might want to consider adding // noframes@ to your metadata block, Derpibooru serves some of its ads from an <iframe>, this prevents the script from running inside of it.
DanielTepesKraus
Greatest Poster in the Board -
GREEN - TALK TO ME
Roseluck - Had their OC in the 2023 Derpibooru Collab.
Elements of Harmony - Had an OC in the 2022 Community Collab
Twinkling Balloon - Took part in the 2021 community collab.
Friendship, Art, and Magic (2020) - Took part in the 2020 Community Collab
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Friendship, Art, and Magic (2019) - Celebrated Derpibooru's seventh year anniversary with friends
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)

will return
@Marker  
good catch!
 
so i have tweaked the code so it now takes pagination into account and will append [image source] links to all pages of comments instead of just the first. also too now it will add [image source] links to applicable images in descriptions and the user’s about me box. added @noframes as well.
 
good point too on nodecreationobserver. really, my only reason for not using such a thing (i didn’t know about it, but i knew of a jquery method to add a “content changed” trigger to a div or span) is i don’t like to use external libraries or anything that needs require to run. the only script of mine that uses even jquery was made before when derpi supported it site-wide (so require wasn’t necessary) and it was pure laziness that kept me from rewriting the script to not use it after jquery was dropped.
Marker
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Magnificent Metadata Maniac - #1 Assistant
Not a Llama - Happy April Fools Day!

Misanthrope
Got another bug report for ya: script inserts a broken link when dealing with derpibooru images embedded with the !! syntax. Example: !https://derpicdn.net/img/2016/12/10/1314002/thumb.png!  
full
 
I recommend checking that GetLinks.indexOf("url=") returns a value that’s not -1 before inserting the links.
DanielTepesKraus
Greatest Poster in the Board -
GREEN - TALK TO ME
Roseluck - Had their OC in the 2023 Derpibooru Collab.
Elements of Harmony - Had an OC in the 2022 Community Collab
Twinkling Balloon - Took part in the 2021 community collab.
Friendship, Art, and Magic (2020) - Took part in the 2020 Community Collab
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Friendship, Art, and Magic (2019) - Celebrated Derpibooru's seventh year anniversary with friends
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)

will return
@Marker  
another good catch! so said bug has been fixed, and i whipped up something a touch experimental. for derpi pics that are linked with !!, instead of [image source] it adds [derpibooru post]] which links you to the relevant post.
Interested in advertising on Derpibooru? Click here for information!
Ministry of Image - Fanfiction Printing

Help fund the $15 daily operational cost of Derpibooru - support us financially!

Syntax quick reference: **bold** *italic* ||hide text|| `code` __underline__ ~~strike~~ ^sup^ %sub%

Detailed syntax guide