anafema / fusker xxx

// ==UserScript==
// @name         fusker xxx
// @namespace    http://tampermonkey.net/
// @version      0.2
// @license MIT
// @description  make slideshow from lids on fusker xxx
// @author       anafema
// @match        *.fusker.xxx/en/?lid*
// @grant        none
// @require https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.33.0/js/blueimp-gallery.min.js
// Whats new?
// - In version 0.2 i have fixed befavour when page was loaded with [spacial=preview] variable, now script havent load
// images from previews
// - Now after you saw last pic in lid, script will load next unseen page
// ==/UserScript==

(function () {
  'use strict';
  var state = false;
  $('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.33.0/css/blueimp-gallery.min.css">');
  let a = $('p img');
  let tlinks = $('#textlinks').html();
  let CountForIndex = a.length - 1;
  $('body').html('<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" style="margin: 0;"><div class="slides"></div><h3 class="title"></h3><a class="prev">‹</a><a class="next">›</a><a class="play-pause"></a><ol class="indicator"></ol></div>');
  $('body').append('<div id="links">')
  a.each(function (index) {
    var link;
    var title;
    //console.log(this);
    title = (index + 1).toString() + " of " + (a.length).toString();
    link = $(this).attr('src');
    $("<a href=\"" + link + "\" title=\"" + title + "\"></a>").append("<img src=\"" + link + "\" style=\"display: none;\" title=\"" + title + "\">").appendTo('#links');
  });

  function GoToNextPage() {
    let pageLinks = $('div.link span a');
    pageLinks.each(function (i, value) {
      if ($(value).attr('style') != 'text-decoration: line-through;') {
        if (value.href == window.location.href) {
          return true;
        }
        else {
          window.location.href = value.href;
        }
        //console.log(value);
        return false;
      }
      window.location.href = $('.paginate a')[0].href;
    });
  };

  document.getElementById('links').onclick = function (event) {
    event = event || window.event;
    var target = event.target || event.srcElement,
      link = target.src ? target.parentNode : target,
      options = {
        index: link,
        event: event,
        startSlideshow: true,
        onslide: function (index, slide) {
          if (state) {
            GoToNextPage();
          }
          if (index == CountForIndex && state == false) {
            state = true;
          }
          //console.log('onslide');
        },
        onopen: function () {
          //console.log('onopen');
          if (a.length == 0) {
            GoToNextPage();
          }
          if (a.length == 1) {
            setTimeout(function () {
              GoToNextPage();
            }, 3000);
          }
        }
      },
      links = this.getElementsByTagName('a');
    blueimp.Gallery(links, options);
  };

  document.getElementById('links').click();
  $('body').append(tlinks);
  $('body').append('<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.33.0/js/blueimp-gallery.min.js"></script>');
})();