아브자막 다운로더

아브자막 다운로더 도우미

  1. // ==UserScript==
  2. // @name 아브자막 다운로더
  3. // @namespace 아브자막 다운로더
  4. // @version 1.71
  5. // @description 아브자막 다운로더 도우미
  6. // @author DandyClubs
  7. // @include /avjamak\.(net|com)/
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js
  9. // @connect *
  10. // @grant GM_xmlhttpRequest
  11. // @grant window.close
  12. // @grant GM_addStyle
  13. // @grant GM_openInTab
  14. // @grant unsafeWindow
  15. // @grant GM_setValue
  16. // @grant GM_getValue
  17. // @license MIT
  18. // @run-at document-end
  19. // ==/UserScript==
  20.  
  21. (function() { var css = document.createElement('link'); css.href = 'https://use.fontawesome.com/releases/v5.15.4/css/all.css'; css.rel = 'stylesheet'; css.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(css); })();
  22.  
  23. GM_addStyle (`
  24.  
  25. .IconSet {
  26. position: absolute;
  27. visibility: hidden;
  28. }
  29.  
  30. .OnOff, .OpenIcon, .NextPage {
  31. cursor: pointer;
  32. color: dodgerblue !important;
  33. font-size: 1.5rem;
  34. z-index: 999;
  35. }
  36. `);
  37.  
  38. const PageURL = window.location !== window.parent.location ? document.referrer : document.location.href;
  39.  
  40. var filename, i, LinkUrl
  41. var OnOff = GM_getValue("OnOff", 'On')
  42.  
  43. Start()
  44.  
  45. $( document ).ready(function() {
  46. if(!/wr_id/.test(PageURL) && /jamakbos|jamakuser|bigsub|jamak_sujung|jamakfreer/.test(PageURL)){
  47. MakeIcon()
  48. }
  49. })
  50.  
  51.  
  52.  
  53. async function Start(){
  54.  
  55. if(!/wr_id/.test(PageURL) && /jamakbos|jamakuser|bigsub|jamak_sujung|jamakfreer/.test(PageURL)){
  56. document.querySelector('.panel-heading').insertAdjacentHTML('beforeend', '<div class="IconSet"></>')
  57. document.querySelector('.IconSet').insertAdjacentHTML('beforeend', '<i class="OnOff fas fa-power-off"></>')
  58. document.querySelector('.IconSet').insertAdjacentHTML('beforeend', '&nbsp;&nbsp;<i class="OpenIcon fas fa-external-link-alt"></>')
  59. document.querySelector('.IconSet').insertAdjacentHTML('beforeend', '&nbsp;&nbsp;<i class="NextPage fas fa-arrow-circle-right"></>')
  60. document.querySelector('.panel-heading').style.setProperty('position', 'relative')
  61.  
  62. document.querySelector('.OnOff').addEventListener("click", function(event) {
  63. event.preventDefault()
  64. event.stopPropagation()
  65. event.stopImmediatePropagation()
  66. if(OnOff == 'On'){
  67. document.querySelector('.OnOff').style.setProperty('color', 'Gray', 'important');
  68. document.querySelector('.OpenIcon').style.visibility = "hidden"
  69. OnOff = GM_setValue("OnOff", 'Off')
  70. OnOff = GM_getValue("OnOff")
  71. }
  72. else{
  73. document.querySelector('.OnOff').style.setProperty('color', 'dodgerblue', 'important');
  74. document.querySelector('.OpenIcon').style.visibility = "visible"
  75. OnOff = GM_setValue("OnOff", 'On')
  76. OnOff = GM_getValue("OnOff")
  77. }
  78. })
  79.  
  80. document.querySelector('.OpenIcon').addEventListener("click", function(event) {
  81. event.preventDefault()
  82. event.stopPropagation()
  83. event.stopImmediatePropagation()
  84. OpenLinks(LinkDB)
  85. })
  86.  
  87. document.querySelector('i.NextPage').addEventListener("click", function(event) {
  88. event.preventDefault()
  89. event.stopPropagation()
  90. event.stopImmediatePropagation()
  91. var pageNumber = document.location.href.match(/(.*page=)(\d+)/) ? Number(document.location.href.match(/(.*page=)(\d+)/)[2]) + 1 : '&page=2'
  92. var PreURL = document.location.href.match(/(.*page=)(\d+)/) ? document.location.href.match(/(.*page=)(\d+)/)[1] : document.location.href
  93. window.location = PreURL + pageNumber
  94. })
  95.  
  96.  
  97. window.addEventListener("resize", function(e) {
  98. MakeIcon()
  99. })
  100. /*
  101. window.addEventListener('scroll', function () {
  102. if(inViewport(document.querySelector('.panel-heading'))){
  103. MakeIcon()
  104. }
  105. }, {
  106. passive: true
  107. })
  108. */
  109. var Linksitems = document.querySelectorAll('div.list-container > div.list-row > div.list-item > h2 > a')
  110. let filtered = [...Linksitems].filter(n => n.textContent.length >= 4)
  111. var LinkDB = []
  112. if(/jamakbos|jamakuser|bigsub/.test(PageURL)){
  113. for (i = 0; i < filtered.length; i++) {
  114. var last = [...filtered[i].closest('div.list-item').querySelectorAll('.list-details.text-muted .pull-right')].pop()
  115. MP = last && last.textContent.match(/(\d+)/) ? Number(last.textContent.match(/(\d+)/).pop()) : ''
  116. if(!MP || MP <=1){
  117. //console.log(filtered[i])
  118. LinkDB.push(filtered[i])
  119. }
  120. }
  121. console.log(LinkDB)
  122. }
  123. else {
  124. LinkDB = Linksitems
  125. }
  126. }
  127. else if(/wr_id/.test(PageURL) && /jamakbos|jamakuser|bigsub|jamak_sujung|jamakfreer/.test(PageURL) && OnOff == 'On'){
  128.  
  129. var links = document.querySelectorAll('a[href*="download.php"]')
  130. var MP = document.querySelector('.fa.fa-bell.red') ? document.querySelector('.fa.fa-bell.red').closest('a.list-group-item').querySelector('b').textContent : ''
  131.  
  132. const getUriWithParam = (baseUrl, params) => {
  133. //console.log(baseUrl)
  134. const Url = new URL(baseUrl);
  135. const urlParams = new URLSearchParams(Url.search);
  136. for (const key in params) {
  137. if (params[key] !== undefined) {
  138. urlParams.set(key, params[key]);
  139. }
  140. }
  141. Url.search = urlParams.toString();
  142. return Url.toString();
  143. };
  144.  
  145.  
  146. for (var i = 0; i < links.length; ++i) {
  147. links[i].href = await getUriWithParam(links[i].href, {ds: "1"})
  148. links[i].href = await getUriWithParam(links[i].href, {js: "on"})
  149. }
  150.  
  151. links = document.querySelectorAll('a[href*="download.php"]')
  152.  
  153. if(!links?.length){
  154. await sleep(5000)
  155. window.close()
  156. }
  157. else{
  158. for (var j = 0; j < links.length; ++j) {
  159. if(!MP){
  160. DownloadFile(links[j].href, links[j])
  161. }
  162. else if( MP > 0){
  163. DownloadFile(links[j].href, links[j])
  164. }
  165. else{
  166. await sleep(5000)
  167. window.close()
  168. }
  169. }
  170. }
  171. }
  172. }
  173.  
  174. function MakeIcon() {
  175. document.querySelector(".IconSet").style.visibility = "visible"
  176. if(OnOff == 'On'){
  177. document.querySelector('.OnOff').style.setProperty('color', 'dodgerblue', 'important');
  178. document.querySelector('.OpenIcon').style.visibility = "visible"
  179. }
  180. else{
  181. document.querySelector('.OnOff').style.setProperty('color', 'Gray', 'important');
  182. document.querySelector('.OpenIcon').style.visibility = "hidden"
  183. }
  184. let TitlePostion = getOffset(document.querySelector('.panel-heading'))
  185. let IconPostion = getOffset(document.querySelector(".IconSet"))
  186.  
  187. $('.IconSet').css({
  188. "top": 10
  189. ,"left": '95%'
  190. })
  191. }
  192.  
  193. function DownloadFile(url, target) {
  194. target.querySelector('i.fa').classList.remove('fa-download')
  195. target.querySelector('i.fa').classList.add('fa-spinner')
  196. target.querySelector('i.fa').style.setProperty('color', 'White', 'important');
  197.  
  198. fetch(url,{
  199. credentials: 'include',
  200. })
  201. .then(async res => {
  202. var disposition = await res.headers.get('Content-Disposition')
  203. console.log(disposition)
  204. target.querySelector('i.fa').style.setProperty('color', 'Orange', 'important');
  205. if(typeof disposition !== 'undefined' && disposition !== null){
  206. filename = disposition.split(/;(.+)/)[1].split(/=(.+)/)[1].replace("utf-8''", '').replace(/['"]/g, '').replace(/\+/g, '%20')
  207. filename = decodeURIComponent(filename)
  208. //console.log(filename)
  209. return res.blob()
  210. }
  211. })
  212. .then(async blob => {
  213. await saveAs(blob, filename)
  214. target.querySelector('i.fa').classList.remove('fa-spinner')
  215. target.querySelector('i.fa').classList.add('fa-check-square')
  216. await sleep(10000)
  217. window.close()
  218. })
  219. .catch((error) => {
  220. console.error('Downloading Error', error);
  221. });
  222. }
  223.  
  224. function inViewport (element) {
  225. if (!element) return false;
  226. if (1 !== element.nodeType) return false;
  227.  
  228. var html = document.documentElement;
  229. var rect = element.getBoundingClientRect();
  230.  
  231. return !!rect &&
  232. rect.bottom >= 0 &&
  233. rect.right >= 0 &&
  234. rect.left <= html.clientWidth &&
  235. rect.top <= html.clientHeight;
  236. }
  237.  
  238. function sleep(ms) {
  239. return new Promise(resolve => setTimeout(resolve, ms));
  240. }
  241.  
  242. function getOffset(el) {
  243. const rect = el.getBoundingClientRect();
  244. return {
  245. left: rect.left + window.scrollX,
  246. top: rect.top + window.scrollY,
  247. right: rect.right + window.scrollX,
  248. width: rect.width,
  249. height: rect.height
  250. };
  251. }
  252.  
  253. async function OpenLinks(LinkDB){
  254. document.querySelector('.OpenIcon').style.setProperty("color", "Orange", "important")
  255. for (var i = 0; i < LinkDB.length; i++) {
  256. LinkUrl = LinkDB[i].href
  257. console.log(LinkUrl)
  258. await GM_openInTab( LinkUrl , { active: false, insert: true } )
  259. await sleep(100)
  260. }
  261. }
  262.  
  263. addJS_Node (null, null, overrideSelectNativeJS_Functions)
  264.  
  265. function overrideSelectNativeJS_Functions () {
  266. window.confirm = function alert (message) { return true; }
  267. }
  268.  
  269. function addJS_Node (text, s_URL, funcToRun) {
  270. var D = document;
  271. var scriptNode = D.createElement ('script');
  272. scriptNode.type = "text/javascript";
  273. if (text) scriptNode.textContent = text;
  274. if (s_URL) scriptNode.src = s_URL;
  275. if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
  276. var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
  277. targ.appendChild (scriptNode);
  278. }

QingJ © 2025

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