Batoto Direct Links

Adds Direct Links to the online reader

  1. // ==UserScript==
  2. // @name Batoto Direct Links
  3. // @namespace https://github.com/ToostInc/userscripts
  4. // @description Adds Direct Links to the online reader
  5. // @include http://www.batoto.net/read/_/*
  6. // @include http://www.bato.to/read/_/*
  7. // @include https://bato.to/read/_/*
  8. // @author Joost Bremmer < toost dot b at gmail dot com >
  9. // @copyright 2014, Joost Bremmer
  10. // @license MIT
  11. // @version 2.1.3.1
  12. // @date 17-07-2015
  13. // @require http://code.jquery.com/jquery-latest.min.js
  14. // @grant GM_addStyle
  15. // @grant GM_xmlhttpRequest
  16. // ==/UserScript==
  17.  
  18.  
  19. // The MIT License
  20. //
  21. // Copyright (c) 2014 Joost Bremmer
  22. //
  23. // Permission is hereby granted, free of charge, to any person obtaining a
  24. // copy of this software and associated documentation files
  25. // (the "Software"), to deal in the Software without restriction,
  26. // including without limitation the rights to use, copy, modify, merge,
  27. // publish, distribute, sublicense, and/or sell copies of the Software, and
  28. // to permit persons to whom the Software is furnished to do so, subject to
  29. // the following conditions:
  30. //
  31. // The above copyright notice and this permission notice shall be included
  32. // in all copies or substantial portions of the Software.
  33. //
  34. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  35. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  36. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  37. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  38. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  39. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  40. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  41. //
  42.  
  43. $(document).ready (function () {
  44.  
  45.  
  46.  
  47.  
  48. //Add various tabs
  49. var dlinks = "<div id='dlinks' class='rounded dlinks'>\n" +
  50. "\t<h3>Direct Links:</h3>\n" +
  51. "\t<br />\n" +
  52. "</div>";
  53. var dlinksanchor = "<li style='display: inline-block; margin-right: 20px;'>\n" +
  54. "\t<button type='button' id='dlinksanchor'>" +
  55. "Direct Links" +
  56. "</button>\n" +
  57. "</li>";
  58.  
  59.  
  60. //insert tabs
  61. $("#read_settings").before(dlinks);
  62. $("div.moderation_bar li:last-child").before(dlinksanchor);
  63.  
  64. //style tabs
  65.  
  66. GM_addStyle(".dlinks {" +
  67. "background-color: #FFFFFF;" +
  68. "padding-top: 10px;" +
  69. "padding-bottom: 05px;" +
  70. "display: none;" +
  71. "text-align: center;" +
  72. "border-top: 1px solid #CDCDCD;" +
  73. "border-top-right-radius:0px;"+
  74. "border-top-left-radius: 0px;" +
  75. "border-bottom: 1px solid #CDCDCD;"+
  76. "z-index: 999; position: absolute;" +
  77. "width: 100%;"+
  78. "left: 0px;"+
  79. "}"
  80. );
  81. $("#comic_wrap").css("z-index","499")
  82.  
  83.  
  84.  
  85.  
  86. //get image source
  87. var imgsrc = $("img#comic_page").attr("src");
  88.  
  89. //get total amount of pages
  90. var pages = $("select#page_select option:last").html();
  91. var pages = pages.replace(/page./g, '');
  92.  
  93.  
  94. //insert links into Direct Links div.
  95. var dlmesg = '<p>\n' +
  96. '\tUse "Right-click > Save As" dialogue,' +
  97. 'or a download manager like ' +
  98. '<a href="http://www.downthemall.net/" id="dta">' +
  99. 'DownThemAll'+
  100. '</a> ' +
  101. 'to save the images.\n' +
  102. '<br /><br />' +
  103. '</p>\n' +
  104. '<a href="#" id="dlloading">' +
  105. '\tLoading...'+
  106. '\t<br />\n' +
  107. '</a>';
  108.  
  109. $("#dlinks").append(dlmesg);
  110.  
  111. //event handler click on 'Direct Links' button.
  112. $("#dlinksanchor").click( function() {
  113.  
  114. $("#dlinks").slideToggle("slow");
  115.  
  116. });
  117.  
  118. $("#page_select:first > option").each(function() {
  119. var nextpage = $(this).attr("value");
  120. //console.log(nextpage);
  121.  
  122. GM_xmlhttpRequest({
  123. method: "GET",
  124. url: nextpage,
  125. onload: function(response) {
  126. //console.log(response.responseText);
  127.  
  128. if ( response.responseText.indexOf('id="comic_page"') > 0 ) {
  129. var raw = response.responseText;
  130. var content = /<img.*comic_page.*>/.exec(raw)
  131. //console.log(content);
  132. var imglink = /"http.*(png|jpg)"/.exec(content);
  133. //console.log(imglink[0]);
  134.  
  135.  
  136. var pagenum = /\d*\.(png|jpg)/.exec(imglink[0]);
  137. //console.log(pagenum[0]);
  138. var newpageanchor= '<a href=' + imglink[0] + 'id="page' +
  139. /\d*/.exec(pagenum[0]) + '">' +
  140. "\n\tPage " + parseInt(/\d*/.exec(pagenum[0])) + "<br />" +
  141. '</a>';
  142.  
  143. }
  144.  
  145. else {
  146. imglink[0] = "image not found!";
  147. var newpageanchor='<a href="#" class="404">Uh-oh.something went wrong</a>' +
  148. '<br />';
  149. }
  150.  
  151. $("#dlinks").append(newpageanchor);
  152.  
  153. //sort links
  154. $('#dlinks a[id^="page"]').sort(function (a, b) {
  155. var re = /[^\d]/g;
  156. return ~~a.id.replace(re, '') > ~~b.id.replace(re, '');
  157. })
  158. .appendTo("#dlinks");
  159.  
  160.  
  161. }
  162. });
  163.  
  164. if ( $(this).is(":last-child") ) {
  165. $("#dlloading").remove();
  166. }
  167.  
  168.  
  169. });
  170.  
  171.  
  172. });
  173.  
  174.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址