NSFWalbum Downloader

Allow getting full album from NFSWalbum.com in an easy way

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         NSFWalbum Downloader
// @namespace    https://nsfwalbum.com/
// @version      1.1
// @description  Allow getting full album from NFSWalbum.com in an easy way
// @author       whatever
// @match        https://nsfwalbum.com/album/*
// @grant        GM_download
// @grant        GM_getResourceURL
// @resource     downloadIcon https://i.imgur.com/sj6kMRp.png
// @require      https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.min.js
// ==/UserScript==

(async function() {
  const giraffe = {
    annihilate: function(r, a) {
      let n = '';
      r.toString();
      for (let t = 0; t < r.length; t++) {
        const e = r.charCodeAt(t) ^ a;
        n += String.fromCharCode(e);
      }
      return n;
    },
  };

  const zeroFill = val => ('00000' + val).substr(-5);

  const links = [];
  const images = document.querySelectorAll('.img.albumPhoto');
  for (let img of images.entries()) {
    links.push(img[1].dataset.imgId);
  }

  const downloadAlbum = async idx => {
    const dlStatus = document.querySelector('.dlStatus');
    if (idx >= links.length) {
      dlStatus.innerText = 'Download complete!';
      return;
    }

    dlStatus.innerText = `Download in progress: ${idx + 1}/${links.length}`;

    const imgPage = await axios.get(`https://nsfwalbum.com/photo/${links[idx]}`);
    const matches = imgPage.data.match(/encodeURIComponent\(giraffe.annihilate\("([^"]+)/i);
    if (matches.length) {
      const spirit = encodeURIComponent(giraffe.annihilate(matches.pop(), 6));
      GM_download({
        url: `https://nsfwalbum.com/imageProxy.php?photoId=${links[idx]}&spirit=${spirit}`,
        name: `nsfwalbum-${document.location.href.split('/').pop()}-${zeroFill(idx + 1)}.jpg`,
        saveAs: false,
        onload: () => {
          downloadAlbum(idx + 1);
        },
        onerror: err => {
          console.error(err);
          downloadAlbum(idx + 1);
        },
      });
    } else {
      console.error('Unable to retrieve spirit for page', `https://nsfwalbum.com/photo/${links[idx]}`);
    }
  };

  const img = document.createElement('img');
  const a = document.createElement('a');
  a.classList = 'downloadAlbum';
  a.appendChild(img);
  a.onclick = () => {
    downloadAlbum(0);
  };
  img.src = await GM_getResourceURL('downloadIcon');
  img.setAttribute('style', 'margin-left: 30px; width: 24px; height: 24px; cursor: pointer;');
  const dlStatus = document.createElement('span');
  dlStatus.classList = 'dlStatus';
  dlStatus.setAttribute('style', 'margin-left: 10px;');
  document
    .querySelector('.gallery_name h6')
    .appendChild(a)
    .appendChild(dlStatus);
})();