fork(1) download
  1. // ==UserScript==
  2. // @name Save
  3. // @namespace http://m...content-available-to-author-only...s.com/*
  4. // @include http://m...content-available-to-author-only...s.com/G*******
  5. // @version 1
  6. // @require http://a...content-available-to-author-only...s.com/ajax/libs/jquery/2.2.2/jquery.min.js
  7. // @grant all
  8. // ==/UserScript==
  9. $(document).ready(function () {
  10. if (/^http:\/\/motherless\.com\/G[^\/]{0,7}$/.test(window.location)) {
  11. type_url = [
  12. ];
  13. getInfo();
  14. makeBox();
  15. }
  16. });
  17. function getInfo() {
  18. g_id = (window.location).toString().match(/http:\/\/motherless\.com\/G([^\/]{0,7})/) [1];
  19. g_title = $('.content-title').html();
  20. g_img = $('.sub_menu').html().match(/.+Images .+\[ (.+) \].+/) [1];
  21. g_vid = $('.sub_menu').html().match(/.+Videos .+\[ (.+) \].+/) [1];
  22. }
  23. function makeBox() {
  24. $('body').append('<div id="box"></div>');
  25. $('#box').css('z-index', '9999').css('position', 'fixed').css('top', '0').css('right', '0');
  26. $('#box').css('background-color', 'rgba(255,255,255,0.9)').css('color', '#000000');
  27. $('#box').append('<div style="font-size:20px;">' + g_title + '</div>');
  28. $('#box').append('<div class="box_img"><a href="">Images: ' + g_img + '</a></div>');
  29. $('#box').append('<div class="box_vid"><a href="">Videos: ' + g_vid + '</a></div>');
  30. $('#box').append('<div class="box_img_ok"></div>');
  31. $('#box').append('<div class="box_vid_ok"></div>');
  32. }
  33. $(document).on('click', '.box_img', function () {
  34. img_list = [
  35. ];
  36. $('#box .box_img_ok').html('Wait Images [' + 0 + '/' + g_img + ']');
  37. getUrls('images', 1);
  38. return false;
  39. });
  40. $(document).on('click', '.box_vid', function () {
  41. vid_list = [
  42. ];
  43. $('#box .box_vid_ok').html('Wait Videos [' + 0 + '/' + g_vid + ']');
  44. getUrls('videos', 1);
  45. return false;
  46. });
  47. function getUrls(type, page = 1) {
  48. type_url['images'] = 'I';
  49. type_url['videos'] = 'V';
  50. $.ajax({
  51. url: 'http://m...content-available-to-author-only...s.com/G' + type_url[type] + g_id + '?page=' + page,
  52. success: function (data) {
  53. $(data).find('a.img-container img').each(function () {
  54. file_info = $(this).attr('src').match(/http:\/\/([a-zA-Z0-9]+)\.thumbs\.motherlessmedia\.com\/thumbs\/([A-Z0-9]+)-(zoom|small)\.(png|jpg|gif|bmp|jpeg)\?from_helper/);
  55. if (type == 'videos') file_info[4] = 'mp4';
  56. file_url = 'http://' + file_info[1] + '.' + type + '.motherlessmedia.com/' + type + '/' + file_info[2] + '.' + file_info[4];
  57. switch (type) {
  58. case 'images':
  59. img_list.push(file_url);
  60. $('#box .box_img_ok').html('Wait Images [' + img_list.length + '/' + g_img + ']');
  61. break;
  62. case 'videos':
  63. vid_list.push(file_url);
  64. $('#box .box_vid_ok').html('Wait Videos [' + vid_list.length + '/' + g_vid + ']');
  65. break;
  66. }
  67. }); /* есть ли ссылка не следующую страницу?*/
  68. if ($(data).find('a:contains(\'NEXT\')').html() !== undefined) {
  69. // есть
  70. nextPage = page + 1;
  71. getUrls(type, nextPage);
  72. } else {
  73. // нет
  74. switch (type) {
  75. case 'images':
  76. $('#box .box_img_ok').html('[Images OK] : Open <a id="img_links" href="">Links</a> or <a id="img_pics" href="">Pics</a>');
  77. break;
  78. case 'videos':
  79. $('#box .box_vid_ok').html('[Videos OK] : Open <a id="vid_links" href="">Links</a> or <a id="vid_pics" href="">Pics</a>');
  80. break;
  81. }
  82. }
  83. }, error: function () {
  84. alert('error');
  85. }
  86. });
  87. }
  88. $(document).on('click', '#img_links', function () {
  89. newWin(g_title + ' (' + g_id + ')' + ' img links', img_list.join('<br/>'));
  90. return false;
  91. });
  92. $(document).on('click', '#img_pics', function () {
  93. content = '';
  94. for (var i = 0; i < img_list.length; i++) {
  95. content = content + '<img alt="" src="' + img_list[i] + '" />';
  96. }
  97. newWin(g_title + ' (' + g_id + ')' + ' Images', content);
  98. return false;
  99. });
  100. $(document).on('click', '#vid_links', function () {
  101. newWin(g_title + ' (' + g_id + ')' + ' vid links', vid_list.join('<br/>'));
  102. return false;
  103. });
  104. $(document).on('click', '#vid_pics', function () {
  105. content = '';
  106. for (var i = 0; i < vid_list.length; i++) {
  107. content = content + '<img alt="" src="' + vid_list[i] + '" />';
  108. }
  109. newWin(g_title + ' (' + g_id + ')' + ' Videos', content);
  110. return false;
  111. });
  112. function newWin(title, content) {
  113. html = '<html>';
  114. html = html + '<head><title>' + title + '</title></head>';
  115. html = html + '</body><code>[ПКМ + Сохранить как]</code><div style="display:none;">';
  116. html = html + content;
  117. html = html + '</div></body>';
  118. html = html + '</html>';
  119. uri = 'data:text/html;charset=utf-8,' + encodeURIComponent(html);
  120. newWindow = window.open(uri);
  121. }
  122.  
Runtime error #stdin #stdout #stderr 0.02s 30432KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:9:0 ReferenceError: $ is not defined