Happy Birthday, MLP:FiM! MLP:FiM turns 9 years old this year! Let's celebrate with an art event!

[Userscript] Forum post/comment source link generator

Started by DanielTepesKraus
Posted
11 replies
Login to subscribe to responses
DanielTepesKraus's avatar
Posts: 9837
DanielTepesKraus
GREEN - TALK TO ME
Greatest Poster in the Board
Artist
Derpibooru Premium - Learn about the benefits of subscribing to Derpibooru Premium membership at https://derpibo
Emerald
Speaking Fancy - For helping with translations
Fine Arts - Two hundred uploads with a score of over a hundred (Safe/Suggestive)
A Perfectly Normal Pony - <DrKraus> "Roger Weiner-Asshole One. Out"
The End wasn't The End - Found a new home after the great exodus of 2012
Best Artist - Providing quality, Derpibooru exclusive artwork
An Artist Who Rocks
A Really Classy Artist
Flexible - Bendy pony
Magnificent Metadata Maniac - #1 Assistant
Thread Starter - Started a thread with over 100 pages (/generals/stupid-stuff-that-comes-to-mind-that-we-want-to-post/)
Friendship, Art, and Magic (5 Years) - Celebrated Derpibooru's five year anniversary with friends.
Responsible Disclosure
Not a Llama - I was once a treehouse! I lived in a cake! But I never saw the way, did the orange slay the rake?
Friendship, Art, and Magic (6 Years) - Celebrated Derpibooru's six year anniversary with friends.
Stolen Condensed Milk - Stole a can of Condensed Milk from Glimmer's private stash while she wasn't looking
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)
Friendship, Art, and Magic (7 Years) - Celebrated Derpibooru's seventh year anniversary with friends
Wallet After Summer Sale

Site Moderator
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:


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:



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's avatar
Posts: 9837
DanielTepesKraus
GREEN - TALK TO ME
Greatest Poster in the Board
Artist
Derpibooru Premium - Learn about the benefits of subscribing to Derpibooru Premium membership at https://derpibo
Emerald
Speaking Fancy - For helping with translations
Fine Arts - Two hundred uploads with a score of over a hundred (Safe/Suggestive)
A Perfectly Normal Pony - <DrKraus> "Roger Weiner-Asshole One. Out"
The End wasn't The End - Found a new home after the great exodus of 2012
Best Artist - Providing quality, Derpibooru exclusive artwork
An Artist Who Rocks
A Really Classy Artist
Flexible - Bendy pony
Magnificent Metadata Maniac - #1 Assistant
Thread Starter - Started a thread with over 100 pages (/generals/stupid-stuff-that-comes-to-mind-that-we-want-to-post/)
Friendship, Art, and Magic (5 Years) - Celebrated Derpibooru's five year anniversary with friends.
Responsible Disclosure
Not a Llama - I was once a treehouse! I lived in a cake! But I never saw the way, did the orange slay the rake?
Friendship, Art, and Magic (6 Years) - Celebrated Derpibooru's six year anniversary with friends.
Stolen Condensed Milk - Stole a can of Condensed Milk from Glimmer's private stash while she wasn't looking
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)
Friendship, Art, and Magic (7 Years) - Celebrated Derpibooru's seventh year anniversary with friends
Wallet After Summer Sale

Site Moderator
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.
Posted Report
Marker's avatar
Posts: 187
Marker
Not a Llama - Happy April Fools Day!
Magnificent Metadata Maniac - #1 Assistant
Wallet After Summer Sale

This Sentence is False
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.
Posted Report
DanielTepesKraus's avatar
Posts: 9837
DanielTepesKraus
GREEN - TALK TO ME
Greatest Poster in the Board
Artist
Derpibooru Premium - Learn about the benefits of subscribing to Derpibooru Premium membership at https://derpibo
Emerald
Speaking Fancy - For helping with translations
Fine Arts - Two hundred uploads with a score of over a hundred (Safe/Suggestive)
A Perfectly Normal Pony - <DrKraus> "Roger Weiner-Asshole One. Out"
The End wasn't The End - Found a new home after the great exodus of 2012
Best Artist - Providing quality, Derpibooru exclusive artwork
An Artist Who Rocks
A Really Classy Artist
Flexible - Bendy pony
Magnificent Metadata Maniac - #1 Assistant
Thread Starter - Started a thread with over 100 pages (/generals/stupid-stuff-that-comes-to-mind-that-we-want-to-post/)
Friendship, Art, and Magic (5 Years) - Celebrated Derpibooru's five year anniversary with friends.
Responsible Disclosure
Not a Llama - I was once a treehouse! I lived in a cake! But I never saw the way, did the orange slay the rake?
Friendship, Art, and Magic (6 Years) - Celebrated Derpibooru's six year anniversary with friends.
Stolen Condensed Milk - Stole a can of Condensed Milk from Glimmer's private stash while she wasn't looking
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)
Friendship, Art, and Magic (7 Years) - Celebrated Derpibooru's seventh year anniversary with friends
Wallet After Summer Sale

Site Moderator
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.
Posted Report
Marker's avatar
Posts: 187
Marker
Not a Llama - Happy April Fools Day!
Magnificent Metadata Maniac - #1 Assistant
Wallet After Summer Sale

This Sentence is False
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!


I recommend checking that GetLinks.indexOf("url=") returns a value that’s not -1 before inserting the links.
DanielTepesKraus's avatar
Posts: 9837
DanielTepesKraus
GREEN - TALK TO ME
Greatest Poster in the Board
Artist
Derpibooru Premium - Learn about the benefits of subscribing to Derpibooru Premium membership at https://derpibo
Emerald
Speaking Fancy - For helping with translations
Fine Arts - Two hundred uploads with a score of over a hundred (Safe/Suggestive)
A Perfectly Normal Pony - <DrKraus> "Roger Weiner-Asshole One. Out"
The End wasn't The End - Found a new home after the great exodus of 2012
Best Artist - Providing quality, Derpibooru exclusive artwork
An Artist Who Rocks
A Really Classy Artist
Flexible - Bendy pony
Magnificent Metadata Maniac - #1 Assistant
Thread Starter - Started a thread with over 100 pages (/generals/stupid-stuff-that-comes-to-mind-that-we-want-to-post/)
Friendship, Art, and Magic (5 Years) - Celebrated Derpibooru's five year anniversary with friends.
Responsible Disclosure
Not a Llama - I was once a treehouse! I lived in a cake! But I never saw the way, did the orange slay the rake?
Friendship, Art, and Magic (6 Years) - Celebrated Derpibooru's six year anniversary with friends.
Stolen Condensed Milk - Stole a can of Condensed Milk from Glimmer's private stash while she wasn't looking
Equality - Was more equal than the rest of the people during the event and did the only smart thing: wasn't there :^)
Friendship, Art, and Magic (7 Years) - Celebrated Derpibooru's seventh year anniversary with friends
Wallet After Summer Sale

Site Moderator
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.
Posted Report
Interested in advertising on Derpibooru? Click here for information!
Ministry of Image - Fanfiction Printing

Derpibooru costs over $25 a day to operate - help support us financially!

Syntax quick reference: *bold* _italic_ [spoiler]hide text[/spoiler] @code@ +underline+ -strike- ^sup^ ~sub~