// ==UserScript==
// @name Pixiv Show All
// @namespace 'vinsai'
// @description Show All original size images in current page, view all images in new page
// @author vinsai
// @version 1.4.1
// @include http://www.pixiv.net/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @downloadURL https://update.greasyfork.icu/scripts/6835/Pixiv%20Show%20All.user.js
// @updateURL https://update.greasyfork.icu/scripts/6835/Pixiv%20Show%20All.meta.js
// ==/UserScript==
var autoLoad = true;
var autoLoadPage = false;
GM_registerMenuCommand("Pixiv Show All->Toggle Auto Load Images", SetAutoLoad);
function SetAutoLoad() {
var auto = GM_getValue(autoLoad);
if (auto == true) {
GM_setValue(autoLoad, false);
}
else {
GM_setValue(autoLoad, true);
}
}
GM_registerMenuCommand("Pixiv Show All->Toggle Auto Load Next Page", SetAutoLoadPage);
function SetAutoLoadPage() {
var auto = GM_getValue(autoLoadPage);
if (auto == true) {
GM_setValue(autoLoadPage, false);
}
else {
GM_setValue(autoLoadPage, true);
}
}
(function () {
var buttonStyle = 'border:1px solid rgb(190,202,215);background:#FCFCFC;padding:2px;cursor:pointer;';
var fixedButtonStyle = 'z-index:2000;position:fixed;left:5px;width:100px;text-align:center;opacity:0.3;';
var imagesWrapperStyle = 'z-index:3000;background-color:#000;text-align:center;position:absolute;top:0px;left:0px;font-family:"メイリオ",Meiryo;';
var imgStyle = 'margin: 5px auto;';
var aStyle = 'color:white;text-align:center;';
var imgDIVStyle = 'margin-bottom:30px;';
var imgTitleStyle = 'font-weight:bold;font-size:180%;';
var imgUserStyle = 'font-size:120%;';
var btn = '';
var btnPage = '';
btnPage += '';
var addStyle =
'\n';
var css =
'\n';
var head = document.getElementsByTagName("head")[0];
if (head) {
head.innerHTML += addStyle;
}
var jquerySrc =
'\n';
var js =
'\n';
var NOT_SHOWN = 'Click the link below to view the images';
var Pixiv = {
NewIllust: {
linkXPath: "//a[@rel='next']",
contentXPath: ["//div[@class='_unit']/ul[@class='image-items autopagerize_page_element'] | //div[@class='_unit']/section[@class='column-search-result'] | //div[@class='_unit']/div[@class='ads_area_no_margin'] | //div[@class='_unit']//nav[@class='column-order-menu'][position()=2]"],
getTitle: function () {
return document.querySelector('.column-title').textContent;
},
getImageNodes: function () {
return document.querySelectorAll('.image-item > .work > img');
},
getIllustURL: function (node) {
return node.parentNode.href;
},
getIllustTitle: function (node) {
var title = "";
if (node.parentNode.querySelector('.title') != null) {
title = node.parentNode.querySelector('.title').textContent;
}
return title;
},
getUser: function (node) {
var user = "";
if (node.parentNode.parentNode.querySelector('a.user') != null) {
user = node.parentNode.parentNode.querySelector('a.user').textContent;
}
return user;
},
getUserURL: function (node) {
var userLink = "";
if (node.parentNode.parentNode.querySelector('a.user') != null) {
userLink = node.parentNode.parentNode.querySelector('a.user').href;
}
return userLink;
}
},
Ranking: {
linkXPath: "//a[@rel='next']",
contentXPath: ["//section[@class='ranking-items autopagerize_page_element']"],
getTitle: function () {
return "";
},
getImageNodes: function () {
return document.querySelectorAll('.ranking-item .data');
},
getIllustURL: function (node) {
var illustLink = "";
if (node.querySelector('h2>a') != null) {
illustLink = node.querySelector('h2>a').href;
}
return illustLink;
},
getIllustTitle: function (node) {
var title = "";
if (node.querySelector('h2>a') != null) {
title = node.querySelector('h2>a').textContent;
}
return title;
},
getUser: function (node) {
var user = "";
if (node.querySelector('.user-container') != null) {
user = node.querySelector('.user-container').textContent;
}
return user;
},
getUserURL: function (node) {
var userLink = "";
if (node.querySelector('.user-container') != null) {
userLink = node.querySelector('.user-container').href;
}
return userLink;
}
},
Bookmark: {
linkXPath: "//a[@rel='next']",
contentXPath: ["//div[@class='display_works linkStyleWorks'] | //nav[@class='column-order-menu']"],
getImageNodes: function () {
return document.querySelectorAll('.display_works img');
},
getIllustURL: function (node) {
return node.parentNode.href;
},
getIllustTitle: function (node) {
return node.parentNode.textContent;
},
getUser: function (node) {
return node.parentNode.parentNode.querySelector('.f10 a').textContent;
},
getUserURL: function (node) {
return node.parentNode.parentNode.querySelector('.f10 a').href;
}
},
Recommend: {
linkXPath: function() {
return Pixiv.Bookmark.linkXPath;
},
contentXPath: function() {
return Pixiv.Bookmark.contentXPath;
},
getImageNodes: function () {
return document.querySelectorAll('.image-item img._thumbnail');
},
getIllustURL: function (node) {
return node.parentNode.href;
},
getIllustTitle: function (node) {
return node.nextSibling.textContent;
},
getUser: function (node) {
var userLink = "";
if (node.parentNode.parentNode.querySelector('a.user') != null) {
userLink = node.parentNode.parentNode.querySelector('a.user').href;
}
return userLink;
},
getUserURL: function (node) {
var userLink = "";
if (node.parentNode.parentNode.querySelector('a.user') != null) {
userLink = node.parentNode.parentNode.querySelector('a.user').href;
}
return userLink;
},
setButton: function () {
Pixiv.setButton(Pixiv.Bookmark);
var btn = '';
$("body").append(btn);
// Show in current page
$('#showAllR').click(function (e) {
var content = Pixiv.CurrentPage.header();
content += Pixiv.getAppendContent(Pixiv.Recommend);
Pixiv.CurrentPage.footer(content);
});
}
},
MemberIllust: {
linkXPath: "//a[@rel='next']",
contentXPath: ["//div[@class='display_works linkStyleWorks'] | //div[@class='_unit manage-unit']/div[@class='clear'] | //div[@class='_unit manage-unit']/ul[@class='column-order-menu'][position()=2]"],
getTitle: function () {
return Pixiv.Illust.getAuthor();
},
getImageNodes: function () {
return document.querySelectorAll('.image-item img._thumbnail');
},
getIllustURL: function (node) {
return node.parentNode.href;
},
getIllustTitle: function (node) {
return node.nextSibling.textContent;
},
getUser: function (node) {
return "";
},
getUserURL: function (node) {
return "";
}
},
Illust: {
doc: document,
getAuthor: function () {
return document.querySelector('.user-link > h1.user').textContent;
},
getTitle: function () {
return this.getAuthor() + '|' + this.getIllustTitle();
},
getImageNode: function () {
return $(this.doc).find('.works_display img').attr('src');
},
getSrcURL: function () {
if (this.getImagesCount() > 1)
return this.getImageNode();
return this.getImageNode().replace("_m.", ".");
},
getIllustTitle: function () {
return $(this.doc).find('.work-info > .title').text();
},
getIlludtID: function () {
return parseInt(location.href.match("id=[0-9]+")[0].substr(3), 10);
},
getImagesCount: function () {
var count = 1;
var str = $(this.doc).find('.work-info > .meta > li:eq(1)').text();
if (str.match("[0-9]+P") != null) {
count = str.match("[0-9]+")[0];
}
return count;
},
getAppendContent: function () {
var urls = this.getImagesURL();
// Get number of images
var count = this.getImagesCount();
var page = "";
for (var i = 0; i < count; ++i) {
page += '
\n';
}
return page;
},
getImagesURL: function () {
var bigImage = "_p";
if (this.getIlludtID() > 11319935) {
bigImage = "_big_p";
}
var p = this.getImageNode();
var url = this.getSrcURL();
var count = this.getImagesCount();
var urls = [];
if (count == 1) {
urls[0] = url;
}
else {
for (var i = 0; i < count; ++i) {
urls[i] = p.replace("_m.", (bigImage + i + "."));
}
}
return urls;
},
autoLoad: function () {
var urls = this.getImagesURL();
var append = "";
for (var i = 0; i < urls.length; ++i) {
append += '';
}
$('.works_display').append(append);
},
setButton: function () {
// Append images to current page
if (GM_getValue(autoLoad) == true) {
Pixiv.Illust.autoLoad();
}
var works = $('.work-info .title');
var btn = '';
var btn2 = '';
works.after(btn + btn2);
// Show in new page
$('#winBtn').click(function (e) {
var page = Pixiv.NewPage.header(Pixiv.Illust);
page += Pixiv.Illust.getAppendContent();
Pixiv.NewPage.footer(page);
});
// Show in current page
$('#winBtn2').click(function (e) {
var content = Pixiv.CurrentPage.header('padding-top:300px;');
content += Pixiv.Illust.getAppendContent();
Pixiv.CurrentPage.footer(content);
});
}
},
NewPage: {
header: function (obj) {
var newPage = "\n