Last active
July 31, 2020 01:31
-
-
Save XtinaSchelin/afa13f2f814fee08c533f825ebfbbb94 to your computer and use it in GitHub Desktop.
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 AO3: Shake Gift | |
// @namespace https://xtinas.org | |
// @match *://*.archiveofourown.org/* | |
// @homepageUrl https://gist.github.com/XtinaSchelin/afa13f2f814fee08c533f825ebfbbb94 | |
// @version 1.0.0.0 | |
// @grant none | |
// ==/UserScript== | |
// FIXME: Handle if there isn't already a .actions item in the work list object. | |
(function($) { | |
$(document).ready(function() { | |
if ( !$('body').hasClass('logged-in') ) { return; } | |
var $base_url = "https://archiveofourown.org/collections/$COLLECTION$/works?commit=Sort+and+Filter&work_search%5Bquery%5D=id%3A$ID$"; | |
var $main = $( '#main' ); | |
var $thurl = ""; | |
$('.index.group li.work', $main).each( function() { | |
var work_id = this.id.replace('work_', ''); | |
var collection = ""; | |
if ( work_id !== '' ) { | |
var $dove = $('div.mystery', this); | |
if ($dove.length > 0) | |
{ | |
collection = $('h5 a', this)[0].getAttribute("href").split("/")[2]; | |
$thurl = $base_url.replace("$COLLECTION$", collection).replace("$ID$", work_id); | |
$('.actions', this).prepend('<a style="float: left; left: 10px; position: absolute;" href="' + $thurl + '">Shake Gift</a>'); | |
} | |
} | |
}); | |
}); | |
})(window.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment