Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Tag Previewer
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Preview tags
- // @author Anon
- // @include /^(http(s)?://)?exhentai.org/?.*/
- // @grant none
- // @require https://code.jquery.com/jquery-3.4.0.min.js
- // ==/UserScript==
- $(document).ready(function() {
- // first selector is for thumbnail view, second is for extended
- $( "div.gl1t, td.gl1e" ).each( function( index, element ){
- // combined namespace + all tags into one string to display at end
- var combined = "";
- // store the link to the actual doujin so we can pull tags
- var href = $(element).find('a').attr('href');
- // store the img since we will modify its title later
- var img = $(element).find('img');
- // delay is in ms, timeout is so we don't instally pull tags when we mouse over stuff
- var delay=1, setTimeoutConst;
- var loaded = false;
- $(img).on("mouseenter", function() {
- // if alread pulled tags, don't do it again. be nice to their servers
- if (loaded) {
- return;
- }
- // start a timer, once 'delay' ms have happened, get tags
- setTimeoutConst = setTimeout(function() {
- $.ajax({
- // make a get request to the doujin page to pull tags
- url: href,
- type: 'GET',
- success: function(res) {
- // get the parent element of each namespace + list of tags
- $(res).find('div#taglist table tbody tr').each( function( index, element ) {
- // separate namespace and tags since we add to the string differently
- var namespace = $(element).find('td.tc');
- var tag = $(element).find("div");
- combined += $(namespace).text() + ' ';
- // iterate tags and add to string
- $(tag).each(function( index, element ) {
- combined += $(element).text() + ', ';
- });
- //strip last ', ' and add a newline
- combined = combined.substring(0, combined.length - 2) + '\n';
- });
- //strip the last '\n'
- combined = combined.substring(0, combined.length - 1);
- $(img).prop('title', combined);
- }
- });
- loaded = true;
- }, delay);
- }).on("mouseleave", function() {
- // if we moved mouse out of image before 'delay' ms, reset the timer
- clearTimeout(setTimeoutConst);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement