IG小助手

一键下载对方 Instagram 帖子中的相片、视频甚至是他们的快拍!

当前为 2022-08-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IG Helper
  3. // @name:zh-TW IG小精靈
  4. // @name:zh-CN IG小助手
  5. // @name:ja IG助手
  6. // @name:ko IG조수
  7. // @namespace https://github.snkms.com/
  8. // @version 2.3.7.3
  9. // @description Downloading Instagram posts photos and videos or their stories!
  10. // @description:zh-TW 一鍵下載對方 Instagram 貼文中的相片、影片甚至是他們的限時動態!
  11. // @description:zh-CN 一键下载对方 Instagram 帖子中的相片、视频甚至是他们的快拍!
  12. // @description:ja 写真、ビデオ、そしてお互いの Instagram 投稿からのストーリーずズのワンクリックダウンロード!
  13. // @description:ko Instagram 게시물에서 사진, 비디오 또는 이야기를 다운로드하십시오.
  14. // @author SN-Koarashi (5026)
  15. // @match https://*.instagram.com/*
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @grant GM_xmlhttpRequest
  19. // @require https://code.jquery.com/jquery-3.6.0.min.js
  20. // @supportURL https://www.facebook.com/smileopwe/
  21. // @icon https://www.google.com/s2/favicons?domain=www.instagram.com
  22. // @compatible firefox >= 87
  23. // @compatible chrome >= 90
  24. // @compatible edge >= 90
  25. // @license GPLv3
  26. // ==/UserScript==
  27.  
  28. (function(jQuery) {
  29. 'use strict';
  30. // Icon download by https://www.flaticon.com/authors/pixel-perfect
  31.  
  32. const $ = jQuery;
  33. const checkInterval = 250;
  34.  
  35. var currentURL = location.href;
  36. var currentHeight = $(document).height();
  37. var firstStarted = false;
  38. var pageLoaded = false;
  39.  
  40. var GL_postPath;
  41. var GL_username;
  42.  
  43. // Main Timer
  44. var timer = setInterval(function(){
  45. currentHeight = $(document).height();
  46.  
  47. // Call Instagram dialog function if url changed.
  48. if(currentURL != location.href || !firstStarted || !pageLoaded){
  49. pageLoaded = false;
  50. firstStarted = true;
  51. currentURL = location.href;
  52.  
  53. if($('div.sspdcydq[role="dialog"]').length || $('main._a993[role="main"]').length){
  54. console.log('isDialog');
  55. setTimeout(()=>{
  56. onReadyMyDW(false);
  57. },150);
  58. pageLoaded = true;
  59. }
  60.  
  61. if(location.href == "https://www.instagram.com/"){
  62. console.log('isHomepage');
  63. setTimeout(()=>{
  64. onReadyMyDW(false);
  65. },150);
  66. pageLoaded = true;
  67. }
  68.  
  69. if(!pageLoaded){
  70. // Call Instagram stories function
  71. if(location.href.match(/^(https:\/\/www\.instagram\.com\/stories\/)/ig)){
  72. console.log('isStory');
  73. onStoryDW(false);
  74. onStoryThumbnailDW(false);
  75.  
  76. if($(".IG_DWSTORY").length) setTimeout(()=>{pageLoaded = true;},150);
  77. }
  78. else{
  79. pageLoaded = false;
  80. // Remove the download icon
  81. $('.IG_DWSTORY').remove();
  82. $('.IG_DWSTORY_THUMBNAIL').remove();
  83. }
  84. }
  85.  
  86. }
  87.  
  88. // Direct Download Checkbox
  89. if(!$('.AutoDownload_dom').length){
  90. let ckValue = (GM_getValue('AutoDownload'))?'checked':'';
  91. $('body ._acuq._acur').append('<div class="AutoDownload_dom" style="position: absolute;left:15px;top:0px;padding:6px;line-height:1;background:#fff;border-radius: 50%;"><label title="Checking it will direct download current photos in the posts." style="cursor:help;"><input type="checkbox" value="1" class="AutoDownload" name="AutoDownload" '+ckValue+' />DDL</label></div>');
  92. }
  93. },checkInterval);
  94.  
  95. // Call general function when user scroll the page
  96. $(document).scroll(function(){
  97. if(currentHeight != $(this).height()){
  98. onReadyMyDW();
  99. }
  100. });
  101.  
  102. // Stories funcion
  103. function onStoryDW(isDownload){
  104. if(isDownload){
  105. let date = new Date().getTime();
  106. let timestamp = Math.floor(date / 1000);
  107. let username = $("body > div section._ac0a header._ac0k ._ac0l div ._ac0q > a").text();
  108.  
  109. if($('body > div section._ac0a video._aa63').length){
  110. // Download stories if it is video
  111. let downloadLink = $('video._aa63 source').attr('src')+'&dl=1';
  112. let type = 'mp4';
  113.  
  114. saveFiles(downloadLink,username,"stories",timestamp,type);
  115. }
  116. else{
  117. // Download stories if it is image
  118. let srcset = $('section._ac0a ._aa64 img._aa63').attr('srcset').split(',')[0].split(' ')[0];
  119. let link = (srcset)?srcset:$('section._ac0a ._aa64 img._aa63').attr('src');
  120.  
  121. let downloadLink = link+'&dl=1';
  122. let type = 'jpg';
  123.  
  124. saveFiles(downloadLink,username,"stories",timestamp,type);
  125. }
  126. }
  127. else{
  128. // Add the stories download button
  129. let style = "position: absolute;right:-40px;top:15px;padding:5px;line-height:1;background:#fff;border-radius: 5px;cursor:pointer;";
  130. if(!$('.IG_DWSTORY').length){
  131. $('body > div section._ac0a').append('<div title="Download" class="IG_DWSTORY" style="'+style+'"><svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve"><g><g><path d="M382.56,233.376C379.968,227.648,374.272,224,368,224h-64V16c0-8.832-7.168-16-16-16h-64c-8.832,0-16,7.168-16,16v208h-64 c-6.272,0-11.968,3.68-14.56,9.376c-2.624,5.728-1.6,12.416,2.528,17.152l112,128c3.04,3.488,7.424,5.472,12.032,5.472 c4.608,0,8.992-2.016,12.032-5.472l112-128C384.192,245.824,385.152,239.104,382.56,233.376z"/></g></g><g><g><path d="M432,352v96H80v-96H16v128c0,17.696,14.336,32,32,32h416c17.696,0,32-14.304,32-32V352H432z"/></g></g></div>');
  132. return true;
  133. }
  134. }
  135. }
  136.  
  137. // Stories Thumbnail funcion
  138. function onStoryThumbnailDW(isDownload){
  139. if(isDownload){
  140. // Download stories if it is video
  141. let srcset = $('section._ac0a ._aa64 img._aa63').attr('srcset').split(',')[0].split(' ')[0];
  142. let downloadLink = (srcset)?srcset:$('section._ac0a ._aa64 img._aa63').attr('src');
  143.  
  144. let date = new Date().getTime();
  145. let timestamp = Math.floor(date / 1000);
  146. let type = 'jpg';
  147. let username = $("body > div section._ac0a header._ac0k ._ac0l div ._ac0q > a").text();
  148. let style = 'margin:5px 0px;padding:5px 0px;color:#111;font-size:1rem;line-height:1rem;text-align:center;border:1px solid #000;border-radius: 5px;';
  149.  
  150. // Download thumbnail
  151. saveFiles(downloadLink,username,"thumbnail",timestamp,type);
  152. }
  153. else{
  154. if($('body > div section._ac0a video._aa63').length){
  155. // Add the stories download button
  156. let style = "position: absolute;right:-40px;top:45px;padding:5px;line-height:1;background:#fff;border-radius: 5px;cursor:pointer;";
  157. if(!$('.IG_DWSTORY_THUMBNAIL').length){
  158. $('body > div section._ac0a').append('<div title="Download video thumbnail" class="IG_DWSTORY_THUMBNAIL" style="'+style+'"><svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512"><circle cx="8.25" cy="5.25" r=".5"/><path d="m8.25 6.5c-.689 0-1.25-.561-1.25-1.25s.561-1.25 1.25-1.25 1.25.561 1.25 1.25-.561 1.25-1.25 1.25zm0-1.5c-.138 0-.25.112-.25.25 0 .275.5.275.5 0 0-.138-.112-.25-.25-.25z"/><path d="m7.25 11.25 2-2.5 2.25 1.5 2.25-3.5 3 4.5z"/><path d="m16.75 12h-9.5c-.288 0-.551-.165-.676-.425s-.09-.568.09-.793l2-2.5c.243-.304.678-.372 1.002-.156l1.616 1.077 1.837-2.859c.137-.212.372-.342.625-.344.246-.026.49.123.63.334l3 4.5c.153.23.168.526.037.77-.13.244-.385.396-.661.396zm-4.519-1.5h3.118l-1.587-2.381zm-3.42 0h1.712l-1.117-.745z"/><path d="m22.25 14h-2.756c-.778 0-1.452.501-1.676 1.247l-.859 2.862c-.16.533-.641.891-1.197.891h-7.524c-.556 0-1.037-.358-1.197-.891l-.859-2.861c-.224-.747-.897-1.248-1.676-1.248h-2.756c-.965 0-1.75.785-1.75 1.75v5.5c0 1.517 1.233 2.75 2.75 2.75h18.5c1.517 0 2.75-1.233 2.75-2.75v-5.5c0-.965-.785-1.75-1.75-1.75z"/><path d="m4 12c-.552 0-1-.448-1-1v-8c0-1.654 1.346-3 3-3h12c1.654 0 3 1.346 3 3v8c0 .552-.448 1-1 1s-1-.448-1-1v-8c0-.551-.449-1-1-1h-12c-.551 0-1 .449-1 1v8c0 .552-.448 1-1 1z"/></svg></div>');
  159. }
  160. }
  161. else{
  162. $('.IG_DWSTORY_THUMBNAIL').remove();
  163. }
  164. }
  165. }
  166.  
  167. // Prepare promise to cache article which contains blob media
  168. function getBlobMedia(postPath){
  169. return new Promise((resolve,reject)=>{
  170. if(!postPath) reject("NOPATH");
  171. let postShortCode = postPath.substring(3, postPath.length - 1);
  172. let getURL = `https://www.instagram.com/graphql/query/?query_hash=2c4c2e343a8f64c625ba02b2aa12c7f8&variables=%7B%22shortcode%22:%22${postShortCode}%22}`;
  173.  
  174. GM_xmlhttpRequest({
  175. method: "GET",
  176. url: getURL,
  177. onload: function(response) {
  178. let obj = JSON.parse(response.response);
  179. resolve(obj.data);
  180. },
  181. onerror: function(err){
  182. reject(err);
  183. }
  184. });
  185. });
  186. }
  187.  
  188. // Main function
  189. function onReadyMyDW(NoDialog){
  190. // Whether is Instagram dialog?
  191. if(!NoDialog){
  192. // Running if it is dialog
  193. $('article[role="presentation"]').each(function(){
  194. $(this).removeAttr('data-snig');
  195. $(this).unbind('click');
  196. });
  197. $('.SNKMS_IG_DW_MAIN,.SNKMS_IG_DW_MAIN_VIDEO').remove();
  198. }
  199. if(NoDialog == false){
  200. var repeat = setInterval(() => {
  201. if($('article[data-snig="canDownload"]').length > 0) clearInterval(repeat);
  202. createArtBtn();
  203. },250);
  204. }
  205. else{
  206. createArtBtn();
  207. }
  208. }
  209.  
  210. function createArtBtn(){
  211. // Add download icon per each posts
  212. $('article[role="presentation"]').each(function(){
  213. // If it is have not download icon
  214. if(!$(this).attr('data-snig')){
  215. console.log("Found article");
  216. var style = "position: absolute;right:15px;top:15px;padding:6px;line-height:1;background:#fff;border-radius: 50%;cursor:pointer;";
  217.  
  218. // Add the download icon
  219. let $childElement = $(this).children("div").children("div");
  220. $childElement.eq($childElement.length - 2).append('<div title="Download" class="SNKMS_IG_DW_MAIN" style="'+style+'"><svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve"><g><g><path d="M382.56,233.376C379.968,227.648,374.272,224,368,224h-64V16c0-8.832-7.168-16-16-16h-64c-8.832,0-16,7.168-16,16v208h-64 c-6.272,0-11.968,3.68-14.56,9.376c-2.624,5.728-1.6,12.416,2.528,17.152l112,128c3.04,3.488,7.424,5.472,12.032,5.472 c4.608,0,8.992-2.016,12.032-5.472l112-128C384.192,245.824,385.152,239.104,382.56,233.376z"/></g></g><g><g><path d="M432,352v96H80v-96H16v128c0,17.696,14.336,32,32,32h416c17.696,0,32-14.304,32-32V352H432z"/></g></g></div>');
  221.  
  222. // Running if user click the download icon
  223. $(this).on('click','.SNKMS_IG_DW_MAIN', async function(e){
  224. GL_username = $(this).parent().parent().parent().attr('data-username');
  225. GL_postPath = $(this).parent().parent().children("div:last-child").children("div").find("div > section").last().prev().find("a").attr("href");
  226.  
  227. // Create element that download dailog
  228. IG_createDM(GM_getValue('AutoDownload'));
  229.  
  230. var style = 'display:block;margin:5px 0px;padding:5px 0px;color:#111;font-size:1rem;line-height:1rem;text-align:center;border:1px solid #000;border-radius: 5px;';
  231.  
  232. // Find video/image element and add the download icon
  233. var s = 0;
  234. var multiple = $(this).parent().parent().find('._aap0 ._acaz').length;
  235. var pathname = window.location.pathname;
  236. var fullpathname = "/"+pathname.split('/')[1]+"/"+pathname.split('/')[2]+"/";
  237.  
  238. // If posts have more than one images or videos.
  239. if(multiple){
  240. var blob = false;
  241. $(this).parent().find('._aap0 ._acaz').each(function(){
  242. let element_videos = $(this).parent().parent().find('video._ab1d');
  243. if(element_videos && element_videos.attr('src') && element_videos.attr('src').match(/^blob:/ig)){
  244. blob = true;
  245. }
  246. });
  247.  
  248.  
  249. if(blob){
  250. createMediaCacheDOM(GL_postPath,".IG_SN_DIG .IG_SN_DIG_MAIN",style,"Loading Blob Media and others...");
  251. }
  252. else{
  253. let blob = false;
  254. $(this).parent().find('._aap0 ._acaz').each(function(){
  255. s++;
  256. let element_videos = $(this).find('video._ab1d');
  257. let element_images = $(this).find('._aagv img');
  258. let imgLink = (element_images.attr('srcset'))?element_images.attr('srcset').split(" ")[0]:element_images.attr('src');
  259.  
  260. if(element_videos && element_videos.attr('src')){
  261. let video_image = element_videos.attr('poster');
  262. let video_url = element_videos.attr('src');
  263.  
  264. $('.IG_SN_DIG .IG_SN_DIG_MAIN').append('<a data-needed="direct" data-name="IGTV" data-type="mp4" data-globalIndex="'+s+'" style="'+style+'" href="javascript:;" data-href="'+video_url+'"><img width="100" src="'+video_image+'" /><br/>- Videos '+s+' -</a>');
  265.  
  266. if(video_url.match(/^blob:/ig)) blob = true;
  267. }
  268. if(element_images && imgLink){
  269. $('.IG_SN_DIG .IG_SN_DIG_MAIN').append('<a data-needed="direct" data-name="photo" data-type="jpg" data-globalIndex="'+s+'" style="'+style+'" href="javascript:;" data-href="'+imgLink+'"><img width="100" src="'+imgLink+'" /><br/>- Image '+s+' -</a>');
  270. }
  271.  
  272. });
  273.  
  274. if(blob){
  275. createMediaCacheDOM(GL_postPath,".IG_SN_DIG .IG_SN_DIG_MAIN",style,"Detect Blob Media, now reloading...");
  276. }
  277. }
  278. }
  279. else{
  280. s++;
  281. let element_videos = $(this).parent().parent().find('video._ab1d');
  282. let element_images = $(this).parent().parent().find('._aagv img');
  283. let imgLink = (element_images.attr('srcset'))?element_images.attr('srcset').split(" ")[0]:element_images.attr('src');
  284.  
  285.  
  286. if(element_videos && element_videos.attr('src')){
  287. let video_image = element_videos.attr('poster');
  288. let video_url = element_videos.attr('src');
  289.  
  290. if(element_videos.attr('src').match(/^blob:/ig)){
  291. createMediaCacheDOM(GL_postPath,".IG_SN_DIG .IG_SN_DIG_MAIN",style,"Loading Blob Media...");
  292. }
  293. else{
  294. $('.IG_SN_DIG .IG_SN_DIG_MAIN').append('<a data-needed="direct" data-name="video" data-type="mp4" data-globalIndex="'+s+'" style="'+style+'" href="javascript:;" data-href="'+video_url+'"><img width="100" src="'+video_image+'" /><br/>- Video '+s+' -</a>');
  295. }
  296. }
  297. if(element_images && imgLink){
  298. $('.IG_SN_DIG .IG_SN_DIG_MAIN').append('<a data-needed="direct" data-name="photo" data-type="jpg" data-globalIndex="'+s+'" style="'+style+'" href="javascript:;" href="" data-href="'+imgLink+'"><img width="100" src="'+imgLink+'" /><br/>- Image '+s+' -</a>');
  299. }
  300. }
  301.  
  302.  
  303. if(GM_getValue('AutoDownload')){
  304. var autoTimer = setInterval(()=>{
  305. if($('a[data-type]').length > 0){
  306. var GB_Index = 1;
  307.  
  308. if(!$('a[data-blob="true"]').length){
  309. let selectionArr = [...$(this).parent().find('._aamk').children('._acnb')];
  310.  
  311. let LeftButton = $(this).parent().parent().find('button._aahh').length;
  312. let RightButton = $(this).parent().parent().find('button._aahi').length;
  313.  
  314. if(LeftButton && !RightButton){ // Left Only
  315. GB_Index = 2;
  316. console.log('Left Only');
  317. }
  318. else if(!LeftButton && RightButton){ // Right Only
  319. GB_Index = 1;
  320. console.log('Right Only');
  321. }
  322. else if(!LeftButton && !RightButton){ // Both Not Exist
  323. GB_Index = 1;
  324. console.log('Both Not Exist');
  325. }
  326. else{ // Both Exist
  327. GB_Index = 2;
  328. console.log('Both Exist');
  329. }
  330. }
  331. else{
  332. console.log('Blob Media');
  333. let selectionArr = ($(this).parent().find('._aamk').children('._acnb').length)?[...$(this).parent().find('._aamk').children('._acnb')]:[...$(this).parent().find('._aamj').children('._acnb')];
  334. let idx = 0;
  335.  
  336. for(let element of selectionArr){
  337. idx++;
  338. if($(element).attr('class').match(/_acnf/g)){
  339. GB_Index = idx;
  340. }
  341. }
  342. }
  343.  
  344. let downloadLink = $('.IG_SN_DIG').find('a[data-globalindex="'+GB_Index+'"]').attr('data-href');
  345. let date = new Date().getTime();
  346. let timestamp = Math.floor(date / 1000);
  347. let type = $('.IG_SN_DIG').find('a[data-globalindex="'+GB_Index+'"]').attr('data-type');
  348. let name = $('.IG_SN_DIG').find('a[data-globalindex="'+GB_Index+'"]').attr('data-name');
  349.  
  350. saveFiles(downloadLink,GL_username,name,timestamp,type);
  351. $('.IG_SN_DIG').remove();
  352. clearInterval(autoTimer);
  353. }
  354. },500);
  355. }
  356. });
  357.  
  358. // Add the mark that download is ready
  359. var username = $(this).find("header div:last-child span > a").text();
  360.  
  361. $(this).attr('data-snig','canDownload');
  362. $(this).attr('data-username',username);
  363. }
  364. });
  365. }
  366.  
  367. async function createMediaCacheDOM(postURL,selector,style,message){
  368. $(`${selector} a`).remove();
  369. $(selector).append('<p style="text-align:center;font-size:20px;" id="_SNLOAD">'+ message +'</p>');
  370. let media = await getBlobMedia(postURL);
  371. let idx = 1;
  372. let resource = media.shortcode_media;
  373.  
  374. // GraphVideo
  375. if(resource.__typename == "GraphVideo" && resource.video_url){
  376. $(selector).append('<a data-blob="true" data-needed="direct" data-name="video" data-type="mp4" data-globalIndex="'+idx+'" style="'+style+'" href="javascript:;" data-href="'+resource.video_url+'"><img width="100" src="'+resource.display_resources[1].src+'" /><br/>- Video '+idx+' -</a>');
  377. idx++;
  378. }
  379. // GraphSidecar
  380. if(resource.__typename == "GraphSidecar" && resource.edge_sidecar_to_children){
  381. for(let e of resource.edge_sidecar_to_children.edges){
  382. if(e.node.__typename == "GraphVideo"){
  383. $(selector).append('<a data-blob="true" data-needed="direct" data-name="video" data-type="mp4" data-globalIndex="'+idx+'" style="'+style+'" href="javascript:;" data-href="'+e.node.video_url+'"><img width="100" src="'+e.node.display_resources[1].src+'" /><br/>- Video '+idx+' -</a>');
  384. }
  385.  
  386. if(e.node.__typename == "GraphImage"){
  387. $(selector).append('<a data-blob="true" data-needed="direct" data-name="photo" data-type="jpg" data-globalIndex="'+idx+'" style="'+style+'" href="javascript:;" data-href="'+e.node.display_resources[e.node.display_resources.length - 1].src+'"><img width="100" src="'+e.node.display_resources[1].src+'" /><br/>- Image '+idx+' -</a>');
  388. }
  389. idx++;
  390. }
  391. }
  392. $("#_SNLOAD").remove();
  393. }
  394.  
  395. // Download and rename files
  396. function saveFiles(downloadLink,username,index,timestamp,type){
  397. fetch(downloadLink).then(res => {
  398. return res.blob().then(dwel => {
  399. const a = document.createElement("a");
  400. const name = username+'-'+index+'-'+timestamp+'.'+type;
  401. a.href = URL.createObjectURL(dwel);
  402. a.setAttribute("download", name);
  403. a.click();
  404. a.remove();
  405. });
  406. });
  407. }
  408.  
  409. // Create the download dialog element funcion
  410. function IG_createDM(a){
  411. let style = (!a)?"position: fixed;left: 0px;right: 0px;bottom: 0px;top: 0px;":"display:none;";
  412. $('body').append('<div class="IG_SN_DIG" style="'+style+';z-index: 500;"><div class="IG_SN_DIG_BG" style="'+style+'z-index:502;background: rgba(0,0,0,.75);"></div><div class="IG_SN_DIG_MAIN" style="z-index: 510;padding:10px 15px;top:7%;position: absolute;left: 50%;transform: translateX(-50%);width: 500px;min-height: 200px;max-height: 550px;overflow-y:auto;background:#fff;border-radius: 7px;"></div></div>');
  413. $('.IG_SN_DIG .IG_SN_DIG_MAIN').append('<div style="position:relative;height:36px;line-height:36px;">Alt+Q [Close]<svg width="26" height="26" class="IG_SN_DIG_BTN" style="cursor:pointer;position:absolute;right:0px;" xmlns="http://www.w3.org/2000/svg" id="bold" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512"><path d="m14.828 12 5.303-5.303c.586-.586.586-1.536 0-2.121l-.707-.707c-.586-.586-1.536-.586-2.121 0l-5.303 5.303-5.303-5.304c-.586-.586-1.536-.586-2.121 0l-.708.707c-.586.586-.586 1.536 0 2.121l5.304 5.304-5.303 5.303c-.586.586-.586 1.536 0 2.121l.707.707c.586.586 1.536.586 2.121 0l5.303-5.303 5.303 5.303c.586.586 1.536.586 2.121 0l.707-.707c.586-.586.586-1.536 0-2.121z"/></svg></div>');
  414. }
  415.  
  416. // Running if document is ready
  417. $(function(){
  418. // Ready~? GO!!
  419. onReadyMyDW();
  420.  
  421. // Close the download dialog if user click the close icon
  422. $('body').on('click','.IG_SN_DIG_BTN,.IG_SN_DIG_BG',function(){
  423. $('.IG_SN_DIG').remove();
  424. });
  425.  
  426. // Hot key [Alt+Q] to close the download dialog
  427. $(window).keydown(function(e){
  428. if (e.keyCode == '81' && e.altKey){
  429. $('.IG_SN_DIG').remove();
  430. e.preventDefault();
  431. }
  432. });
  433. $('body').on('click','.AutoDownload',function(){
  434. if($('.AutoDownload:checked').length){
  435. GM_setValue('AutoDownload',true);
  436. }
  437. else{
  438. GM_setValue('AutoDownload',false);
  439. }
  440. });
  441.  
  442. $('body').on('click','a[data-needed="direct"]',function(){
  443. let date = new Date().getTime();
  444. let timestamp = Math.floor(date / 1000);
  445. saveFiles($(this).attr('data-href'),GL_username,$(this).attr('data-name'),timestamp,$(this).attr('data-type'));
  446. });
  447.  
  448. // Running if user left-click download icon in stories
  449. $('body').on('click','.IG_DWSTORY',function(){
  450. onStoryDW(true);
  451. });
  452.  
  453. // Running if user left-click download icon in stories
  454. $('body').on('click','.IG_DWSTORY_THUMBNAIL',function(){
  455. onStoryThumbnailDW(true);
  456. });
  457. });
  458.  
  459. })(jQuery);

QingJ © 2025

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