您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Loads all manga pages at once in a simplified vertical layout
当前为
// ==UserScript== // @name Eza's Pixiv Fixiv // @namespace https://inkbunny.net/ezalias // @description Loads all manga pages at once in a simplified vertical layout // @license Public domain / No rights reserved // @include http://www.pixiv.net/member_illust.php?mode=manga&illust_id=* // @version 1.7 // ==/UserScript== // On manga pages, load all images without having to manually scroll to each one. // Pixiv is terribly designed. Maybe it's a cultural Japanese thing, where they still expect single-page click-and-wait browsing like it's still 1998. The site is just openly hostile to users' time and enjoyment. // To wit, I recommend Eza's Image Glutton, which directs from the "medium" landing pages to either the full-size single image or the manga page. Tedium is for robots. // Ideally we'd trigger whatever mechanism tells the page to load each image. // Three problems with that: I'm an HTML/JS amateur, the coders didn't speak much English, and - crucially - we'd still be loading medium-size images. // So instead we're going to scrape the page for URLs, build our own no-bullshit HTML, and replace the entire Body of the page. // Pixiv's super-paranoid anti-hotlinking mechanisms will not trigger because it only sees one of its own pages requesting these images. We don't have to worry about 403s. // mmmaybe replace the custom click-to-advance page with a thumbnail page that instead links to the full-size images? less scrolling through meh, less looking at full-size squick, but more clicking and ctrl+w'ing. // can I just 'touch' all the pages and force them to load within pixiv's own source? I mean, I'm essentially recreating their page now. // I could also just regex document.body.innerHTML for big images. I think the 'small' mode scales them instead of loading some smaller file. // <script>pixiv.context.images[1] = 'http://i2.pixiv.net/img108/img/ukaban/29548141_p1.jpg';pixiv.context.thumbnailImages[1] = 'http://i2.pixiv.net/img108/img/ukaban/mobile/29548141_128x128_p1.jpg';</script></div><div class="item-container"><script>pixiv.context.pages[1] = [2];</script><a href="/member_illust.php?mode=manga_big&illust_id=29548141&page=1" target="_blank" class="full-size-container ui-tooltip" data-tooltip="オリジナルサイズを表示"><i class="_icon sprites-full-size"></i></a><img src="http://source.pixiv.net/www/images/common/transparent.gif" class="image ui-scroll-view" data-filter="manga-image" data-src="http://i2.pixiv.net/img108/img/ukaban/29548141_p1.jpg" data-index="1"> // Should Pixiv Fixiv load real thumbnails? Pixiv provides them. It's not like Tumblr Scrape where you want to save the small images; they only exist to provide an overview. // Using full-size images indicates when they're done loading. // Pixiv is now screwing with Image Toolbar. The toolbar appears with big icons and text labels (doubled text labels, in fact), and middle-clicking doesn't work. I hate this website. // Why is this script running on e.g. http://www.pixiv.net/member_illust.php?mode=medium&illust_id=47549579 ? The single @include here obviously doesn't match. Is the "?" a wildcard? // Once the img-original thing works, add an option (using GM API) to switch between 1200-size and original-size images. // Arg. @grant fucked me. '@grant none' says 'gm_getsetting not found.' '@grant gm_getsetting' says 'pixiv (the array) not found.' fuck your scope bullshit, greasemonkey. be unsafe and useful. // onError should only have to suss out image extensions once per image. Break it out into a function (onError="myFunction()") and have it change the big-image src's as well as the image-link href's. // Some test URLs: // Full-size GIF images: http://www.pixiv.net/member_illust.php?mode=manga&illust_id=28640373 // Size issues: http://www.pixiv.net/member_illust.php?mode=manga&illust_id=47191879 // Unremarkable: http://www.pixiv.net/member_illust.php?mode=manga&illust_id=40231530 var html_dump = document.getElementsByTagName('html')[0].innerHTML; // read full page HTML as string - admittedly overkill, but it's kilobytes, so who really cares? (Could be a reference if it matters.) var thumbnail_html = ""; var options_html = ""; var new_html = ""; // Build a simplified version of the manga page, using high-res images. Clicking an image jumps to the next one. (Keyboard controls not implemented.) for( var page_number = 0; page_number < pixiv.context.images.length; page_number++ ) { var page_url = pixiv.context.images[ page_number ]; // Pixiv now helpfully provides a <script>-generated array of URLs. page_url = page_url.replace( 'c/1200x1200/img-master', 'img-original' ); // Change 1200-sized URL into original-sized URL page_url = page_url.replace( '_master1200', '' ); page_url = page_url.replace( '.png', '.jpg' ); // Change PNG to JPG - so we only have to do JPG->PNG in our onError function. page_url = page_url.replace( '.gif', '.jpg' ); // Same deal, change GIF to JPG. onError cycles from JPG -> PNG -> GIF. // onError function rotates incorrect file extensions, since the right one can't be sussed out beforehand. var image_onerror = 'this.src=this.src.replace(\".png\",\".gif\"); this.src=this.src.replace(\".jpg\",\".png\");' // Display thumbnails for an overview of this manga's contents (and easy links to each page) thumbnail_html = thumbnail_html + "<a href='#" + page_number + "'>"; // link thumbnail to the relevant page anchor thumbnail_html = thumbnail_html + "<img src='" + page_url + "' height='100' width='auto' onerror='" + image_onerror + "'></a> "; // Display pages centered, each linked to the next, kind of like Pixiv does new_html = new_html + "<a id='" + page_number + "'>"; // Anchor, to be linked to by top thumbnails and the previous page new_html = new_html + "<a href='#" + (1.0+page_number) + "'>"; // Link this image to the next image's anchor // This onError additionally changes the associated text link to match the image: new_html = new_html + "<img class='display' src='" + page_url + "' onerror='" + image_onerror + " getElementById(\""+page_number+"link\").href=this.src;'></a></br>"; new_html = new_html + "<a id='" + page_number + "link' href='" + page_url + "'>Image link</a><br><br>"; // Link to the image, so it's easy to open a particular page in tabs } // Create controls for image size, since full-size images can be extremely large. var scale_html = "Scale images: "; // Fit-to-window options for full-size images. var onclick_height = 'var display_images = document.getElementsByClassName("display");'; // Grab all class=display images, change style to 100% view-height. onclick_height = onclick_height + 'for(x=display_images.length-1;x>=0;x--) { display_images[x].style.height="100vh"; display_images[x].style.width="auto"; }'; scale_html = scale_html + "<button onclick='" + onclick_height + "'>Fit height</button> "; var onclick_width = 'var display_images = document.getElementsByClassName("display");'; onclick_width = onclick_width + 'for(x=display_images.length-1;x>=0;x--) { display_images[x].style.width="100vw"; display_images[x].style.height="auto"; }'; scale_html = scale_html + "<button onclick='" + onclick_width + "'>Fit width</button> "; var onclick_original = 'var display_images = document.getElementsByClassName("display");'; onclick_original = onclick_original + 'for(x=display_images.length-1;x>=0;x--) { display_images[x].style.height="auto"; display_images[x].style.width="auto"; }'; scale_html = scale_html + "<button onclick='" + onclick_original + "'>Original sizes</button> "; // Replace page with our custom HTML. new_html = new_html + "<br><br><br><a id = '" + pixiv.context.images.length + "'></a>"; // add one last anchor tag, so clicking the last image brings you to the end of the page thumbnail_html = thumbnail_html + "<br>" + scale_html; new_html = thumbnail_html + "<center><br>"+options_html+"<br>" + new_html; // thumbnails first, then main images document.body.innerHTML = new_html; // replace the HTML body with new_html, which should now contain a long list of <img>s that load in a sensible manner