Sleazy Fork is available in English.

MICIDOL|CEVERIA|TELEGRA.PH 写真打包

MIC IDOL等网站写真打包下载,更多站点的支持以后添加。

< Opiniones de MICIDOL|CEVERIA|TELEGRA.PH 写真打包

Pregunta o comentario

§
Publicado: 14/2/2022

我自己稍微改了一下,可以下载everia了,也支持顺序下载,命名为数字,因为是强制等请求完后再下一个,所以下载速度比之前慢很多。
支持MICIDOL,everia,www.xinmeitulu.com

// ==UserScript==
// @name 写真打包3
// @namespace http://tampermonkey.net/
// @version 0.3.2
// @description MIC IDOL等网站写真打包下载,更多站点的支持以后添加。
// @author JIBI
// @match https://www.micmicidol.com/*/*/*.html
// @match http*://everia.club/*/*/*/*/
// @match https://www.xinmeitulu.com/*
// @match http://www.saladpuncher.com/*
// @icon https://www.google.com/s2/favicons?domain=micmicdoll.com
// @grant GM_xmlhttpRequest
// @require https://cdn.bootcdn.net/ajax/libs/jszip/3.7.1/jszip.min.js
// @require https://cdn.bootcdn.net/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js

// ==/UserScript==
(function () {
'use strict';
const sites = {
MICIDOL: 'MICIDOL',
EVERIA: 'EVERIA',
TELEGRAPH:'TELEGRAPH',
xinmeitulu:'xinmeitulu',
saladpuncher:'saladpuncher'
}


let is_down = false;
let site = sites.MICIDOL;
let host = location.host;
function contains(key){
return host.indexOf(key)!=-1;
}
if (contains('everia')) {
site = sites.EVERIA;
}else if(contains('telegra')){
site = sites.TELEGRAPH;
}else if(contains('xinmeitulu')){
site = sites.xinmeitulu;
}else if(contains('saladpuncher')){
site = sites.saladpuncher;
}

let log = console.log;

const title_rules = {
MICIDOL: 'h3[class="post-title entry-title"]',
EVERIA: 'h1[class="title entry-title"]',
TELEGRAPH:'header[class="tl_article_header"] h1',
xinmeitulu:'h1[class="h3"]',
saladpuncher:'a[class="entry-title"]'
}
const image_rules = {
MICIDOL: 'div.post-body.entry-content a[href] img',
//EVERIA: 'noscript',
EVERIA: 'div.entry-content figure.has-nested-images figure.wp-block-image noscript',
//EVERIA: 'div.entry-content div a[href] img',
TELEGRAPH:'div.figure_wrapper img',
xinmeitulu:'div.text-center figure a[href] img',
saladpuncher:"div.rsTmb img"
}
let title = document.querySelector(title_rules[site]).innerText.trim();
log(title);
let show = document.createElement('button');

const btn_style = '.show_btn{position:fixed;left:50px;bottom:50px;width: 50px; height: 50px; border-radius:50%;border: none;background-color: #f44949;border: 1px solid #f44949;color:#fff;padding:0;}' +
'.show_btn:active{background-color: #ca8e9f;}'
let t = document.createElement('style');
t.innerText = btn_style;
document.querySelector('head').appendChild(t);
show.innerText = 'DOWNLOAD';
show.setAttribute('class', 'show_btn');
document.body.appendChild(show);

function request(url, referrerStr, timeoutInt = 100000) {
return new Promise((resolve, reject) => {
//console.log(`发起网址请求:${url}`);
GM_xmlhttpRequest({
url,
method: 'GET',
overrideMimeType: 'text/plain; charset=x-user-defined',
headers: {
"Cache-Control": "no-cache",
referrer: referrerStr
},
timeout: timeoutInt,
onload: response => { //console.log(url + " reqTime:" + (new Date() - time1));
response.loadstuts = true;
resolve(response);
},
onabort: response => {
console.log(url + " abort");
response.loadstuts = false;
resolve(response);
},
onerror: response => {
console.log(url + " error");
//console.log(response);
response.loadstuts = false;
resolve(response);
},
ontimeout: response => {
console.log(`${url} ${timeoutInt}ms timeout`);
response.loadstuts = false;
response.finalUrl = url;
resolve(response);
},
});
});
}

let imgs = [];
function ForMICIDOL(){
let img_eles = document.querySelectorAll(image_rules[site]);
///log(img_eles);

for (let x of img_eles) {
if (x.getAttribute('width') != null || x.getAttribute('data-original-width') != null) {
x = x.parentElement;
}
let img_url = x.href !== undefined ? x.href : x.src;
imgs.push(img_url);

//let img_url = x.innerHTML !== undefined ? x.innerHTML : x.src;
//log(img_url);
//var img_url2 = img_url;
//let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; // 匹配图片中的src
//img_url2 = img_url2.match(srcReg);
//log(img_url2);
//imgs.push(img_url2[1]);
}
}

function ForSaladpuncher(){
let img_eles = document.querySelectorAll(image_rules[site]);
for (let x of img_eles) {
if (x.getAttribute('width') != null || x.getAttribute('data-original-width') != null) {
x = x.parentElement;
}
let img_url = x.href !== undefined ? x.href : x.src;
//log(img_url.replace(/-96x72/g, ""));
imgs.push(img_url.replace(/-96x72/g, ""));
}
}

let srcArr = []
function ForEVERIA(){
let article = document.getElementsByTagName("article")[0].innerHTML;
//log(article);
let noscriptReg = /

.*?(?:>|\/>)/gi //匹配图片中的img标签
// /|\/>)/gi

let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i // 匹配图片中的src
let arr = article.match(noscriptReg) //筛选出所有的img
//log(arr)

for (let i = 0; i < arr.length; i++) {
let src = arr[i].match(srcReg)
// 获取图片地址
srcArr.push(src[1])
}
//log(srcArr)
//imgs = imgs.filter((x)=>x.endsWith('.jpg'));
//log(imgs)
}

log(site)
if (site=="MICIDOL"){
ForMICIDOL();
}else if (site=="xinmeitulu"){
ForMICIDOL();
}else if (site=="saladpuncher"){
ForSaladpuncher();
}else if (site=="EVERIA"){
ForEVERIA();
imgs=srcArr
}

let num = imgs.length;
log('total img: ',num);
let downloaded = 0;
let zip = new JSZip();
let folder = zip.folder(title);
let promises = [];
let j = 1;
async function zip_img() {
for (const img of imgs) {
try{
let p = request(img)
//let p = request(img)
await p.then(res => {
// let url = res.url;
if(res.loadstuts==false){
throw new Error('下载失败');
}
let imgarr = img.split('/');
let img_name = imgarr[imgarr.length - 1];
// 重复两次是因为有部分真的进行了两次编码,真的蛋疼
img_name = decodeURIComponent(img_name);
img_name = decodeURIComponent(img_name);
img_name = img_name.replace('?','');
if(img_name.length>50){
img_name = img_name.slice(-50);
}
//if (!img_name.endsWith('.webp')) {
// img_name += '.webp';
//}
if (site=="MICIDOL"){
img_name = j +".jpg"
j++;
}
if (site=="xinmeitulu"){
img_name = j +".jpg"
j++;
}
if (site=="saladpuncher"){
img_name = j +".jpg"
j++;
}
if (site=="EVERIA"){
var index=img_name.lastIndexOf("\.");
img_name=img_name.substring(index+1,img_name.length);
img_name = j +"."+img_name;
j++;
}
log('下载完成: ' + img_name)
var r = res.responseText, data = new Uint8Array(r.length), i = 0;
while (i < r.length) {
data[i] = r.charCodeAt(i);
i++;
}
var blob = new Blob([data], { type: 'image/jpeg' }); // 转为Blob类型
folder.file(img_name, blob, { binary: true }); // 压入zip中
downloaded++;
show.innerText = `waiting ${downloaded}/${num}`;
console.log(`waiting ${downloaded}/${num}`);
}).catch(reason => {
console.log('download error: ', reason);
})
promises.push(p);
}catch(err){
console.error(err);
}
}
Promise.all(promises).then(() => {
is_down = true;
show.enable = true;
show.innerText = 'COMPELETE!'
log(`共下载: ${downloaded}/${num}`)
zip.generateAsync({ type: "blob", base64: true }).then(function (content) {
saveAs(content, title + ".zip");
});
}).catch(reason =>{
log('final error -> ',reason)
})

}

show.onclick = function () {
if (!is_down) {
show.enable = false;
show.innerText = 'please wait...'
zip_img();
} else {
log('已下载,请勿重复点击!')
}
}

})();

感谢老哥,直接把你贴过来的代码在油猴里复制保存,是这样用的吗,但是好像没有下载按钮啊

老哥,第150行:let noscriptReg = /报错了,eslint:null-Parsing error: Unterminated regular expression

§
Publicado: 29/5/2022

确实,没有下载按钮,150行是不是少了东西?

§
Publicado: 18/7/2022
Editado: 18/7/2022

老哥,第150行:let noscriptReg = /报错了,eslint:null-Parsing error: Unterminated regular expression

哈哈哈,我才发现,150-152 这三行断开了,放到一行就行了。不过按钮虽然有了,但 everia 好像还不能下载,其它可以了

let noscriptReg = /.*?(?:>|\/>)/gi //匹配图片中的img标签

Publicar respuesta

Inicia sesión para responder.