Komica Save

Save the Komica thread

  1. // ==UserScript==
  2. // @name Komica Save
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-08-24_25h40m
  5. // @description Save the Komica thread
  6. // @author hangjeff
  7. // @match https://gita.komica1.org/00b/*
  8. // @match https://2cha.org/*
  9. // @match https://gaia.komica1.org/*/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Your code here...
  17.  
  18. $('.thread').each(function(){
  19. let Komica_Thread_Url = window.location.href;
  20. if(!Komica_Thread_Url.includes('res')){
  21. Komica_Thread_Url = Komica_Thread_Url.substring(0, Komica_Thread_Url.lastIndexOf('/') + 1);
  22. if(!($(this).find('.threadpost').find('.post-head').find('.rlink').find('a').first().attr('href') === undefined) )
  23. Komica_Thread_Url = Komica_Thread_Url + $(this).find('.threadpost').find('.post-head').find('.rlink').find('a').first().attr('href');
  24. else
  25. Komica_Thread_Url = Komica_Thread_Url + $(this).find('.threadpost').find('.category a:last').attr('href');
  26. }
  27.  
  28. $(this).find('.threadpost').after(ArchiveIs_Create(Komica_Thread_Url, 'Thread'));
  29. $(this).find('.threadpost').after(WebArchive_Create(Komica_Thread_Url, 'Thread'));
  30.  
  31. if($(this).find('.file-thumb').length){
  32. let Komica_File_Url = 'https:' + $(this).find('.file-thumb').attr('href');
  33.  
  34. if($(this).find('.file-thumb').attr('href').includes('.webm') || $(this).find('.file-thumb').attr('href').includes('.mp4')){
  35. $(this).find('.file-text').first().append(WebArchive_Create(Komica_File_Url, 'Video'));
  36. }
  37. else{
  38. $(this).find('.file-text').first().append(WebArchive_Create(Komica_File_Url, 'Image'));
  39. $(this).find('.file-text').first().append(GhostArchive_Create(Komica_File_Url, 'Image'));
  40. }
  41. }
  42.  
  43. })
  44.  
  45. reply_Class_Read();
  46. $(document).ready(function() {
  47. $(document).on('click', '.-expand-thread', function() {
  48. setTimeout(function(){
  49. reply_Class_Read();
  50. console.log('Done!');
  51. }, 1000);
  52. });
  53. });
  54.  
  55. function reply_Class_Read(){
  56. $('.reply').each(function(){
  57. if($(this).find('.file-thumb').length){
  58. if(!$(this).find('form').length){
  59. let Komica_File_Url = 'https:' + $(this).find('.file-thumb').attr('href');
  60. if($(this).find('.file-thumb').attr('href').includes('.webm') || $(this).find('.file-thumb').attr('href').includes('.mp4')){
  61. $(this).find('.file-text').append(WebArchive_Create(Komica_File_Url, 'Video'));
  62. }
  63. else{
  64. $(this).find('.file-text').append(WebArchive_Create(Komica_File_Url, 'Image'));
  65. $(this).find('.file-text').append(GhostArchive_Create(Komica_File_Url, 'Image'));
  66. }
  67. }
  68. }
  69. })
  70. }
  71.  
  72. function WebArchive_Create(myUrl, myTarget){
  73. let form = $('<form>', {
  74. name: 'wwmform_save',
  75. action: 'https://web.archive.org/save',
  76. method: 'POST',
  77. target: '_blank'
  78. }).css('display', 'inline-block');
  79.  
  80. form.append(
  81. $('<input>', {
  82. id: 'url',
  83. type: 'hidden',
  84. name: 'url',
  85. value: myUrl
  86. })
  87. );
  88.  
  89. form.append(
  90. $('<input>', {
  91. type: 'submit',
  92. value: 'Save ' + myTarget + ' to Web archive',
  93. })
  94. );
  95. return form;
  96. }
  97.  
  98. function ArchiveIs_Create(myUrl, myTarget){
  99. let form = $('<form>', {
  100. id: 'submiturl',
  101. action: 'https://archive.ph/submit/',
  102. method: 'GET',
  103. target: '_blank'
  104. }).css('display', 'inline-block');
  105.  
  106. form.append(
  107. $('<input>', {
  108. id: 'url',
  109. type: 'hidden',
  110. name: 'url',
  111. value: myUrl
  112. })
  113. );
  114.  
  115. form.append(
  116. $('<input>', {
  117. type: 'submit',
  118. value: 'Save ' + myTarget + ' to archive.is',
  119. tabindex: '1'
  120. })
  121. );
  122. return form;
  123. }
  124.  
  125. function GhostArchive_Create(myUrl, myTarget){
  126. let form = $('<form>', {
  127. id: 'submiturl',
  128. action: 'https://ghostarchive.org/archive2',
  129. method: 'POST',
  130. target: '_blank'
  131. }).css('display', 'inline-block');
  132.  
  133. form.append(
  134. $('<input>', {
  135. id: 'url',
  136. type: 'hidden',
  137. name: 'archive',
  138. value: myUrl
  139. })
  140. );
  141.  
  142. form.append(
  143. $('<input>', {
  144. type: 'submit',
  145. value: 'Save ' + myTarget + ' to ghostarchive.org',
  146. tabindex: '1'
  147. })
  148. );
  149.  
  150. return form;
  151. }
  152.  
  153. })();