Guest User

Untitled

a guest
Sep 28th, 2022
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         vsco.co downloader
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://vsco.co/*/gallery
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=vsco.co
  9. // @grant        GM_download
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.   window.addEventListener('load', () => {
  16.       addButton('download all images', selectReadFn)
  17.     })
  18.  
  19.  
  20.     function addButton(text, onclick, cssObj) {
  21.         cssObj = cssObj || {position: 'absolute', bottom: '7%', left:'4%', 'z-index': 3};
  22.         var button = document.createElement('button'), btnStyle = button.style;
  23.         document.body.appendChild(button);
  24.         button.innerHTML = text;
  25.         button.onclick = onclick;
  26.         Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key]);
  27.         return button;
  28.     }
  29.  
  30.     function selectReadFn() {
  31.         var subname = prompt("Enter sub name:");
  32.         document.querySelectorAll('section > div > div > figure > a > div > div > img').forEach(el => {
  33.             var src = el.getAttribute("src");
  34.             src = src.replace('?w=260', '');
  35.             src = src.slice(2);
  36.             var name = src.split('/')[4] +'.' + src.split('/')[5];//.split('.')[0];
  37.             if (src != null && name != null && subname != null)
  38.             {
  39.                 console.log('Download ' + src);
  40.                 var arg = {
  41.                     url: 'https://' + src,
  42.                     name: subname + "_" + name
  43.                 };
  44.                 GM_download(arg);
  45.             }
  46.             else
  47.             {
  48.                 console.log('Cannot download ' + src);
  49.             }
  50.         });
  51.     }
  52.  
  53. })();
Advertisement
Add Comment
Please, Sign In to add comment