// ==UserScript== // @name Library Genesis // @version 0.1.1 // @description Open search results in new tab and automatically trigger the download. // @match *://libgen.io/search.php* // @match *://libgen.io/ads.php* // @match *://libgen.io/_ads/* // @match *://libgen.pw/item/* // @require http://code.jquery.com/jquery-latest.js // @namespace https://greasyfork.org/users/5782 // @downloadURL none // ==/UserScript== $(document).ready(function() { var addBlankTarget = function() { /* var selector = 'table.c a[title="Libgen.io"], '; selector += 'table.c a[title="Libgen.pw"], '; selector += 'table.c a[title="Bookfi.net"], '; selector += 'table.c a[title~="Bookzz.org"]'; */ var selector = 'table.c tr:not(:first-child) a'; $(selector).attr('target', '_blank'); } var Downloader = { TIMEOUT: 500, init: function(href) { if (href.includes('libgen.io/_ads/')) { Downloader.initLibgenio(); } else if (href.includes('libgen.pw/item')) { Downloader.initLibgenpw(); } }, initLibgenio: function() { Downloader.showSpinner(); setTimeout(function() { var href = $('body > table td#info h2 a').attr('href'); window.location.replace(href); }, Downloader.TIMEOUT); }, initLibgenpw: function() { Downloader.showSpinner(); setTimeout(function() { if ($('.book-info__download a').length > 0) { window.location.href = $('.book-info__download a').attr('href'); } else if ($('.book-info__get a').length > 0) { window.location.replace($('.book-info__get a').attr('href')); } }, Downloader.TIMEOUT); }, showSpinner: function() { $('head').append(''); $('body').append('
'); $('