// ==UserScript== // @name Pixiv Simplifier // @version 1.0 // @namespace http://www.pixiv.net/2points // @description Removes some annoyances from Pixiv. // @include http://www.pixiv.net/* // @run-at document-end // ==/UserScript== if (!document.body) return; var navigateTo = function(url) { document.location.replace(url); }; /// Open image directly instead of embedded in Pixiv page (for easier saving) var ImagesOpenDirectly = function() { // Check if the user is on a big image page if (window.location.href.match("mode=big")) { // Find the first image on the site var imgTags = document.getElementsByTagName("img") // Redirect the user to this image if (imgTags.length > 0) { navigateTo(imgTags[0].src); } } }; /// Remove target=_blank from all image hyperlinks #########################################################var LinksOpenInSameWindow = function() { // Find all hyperlinks that contain an image tag var imgLinks = document.evaluate("//img/parent::a[@target]", document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); // Iterate through those links for (var i = 0; i < imgLinks.snapshotLength; ++i) { var link = imgLinks.snapshotItem(i); // Remove the target attribute link.removeAttribute("target"); } }; // Loads manga pages before the user scrolls them into view var PreloadMangaPages = function() { if (window.location.search.indexOf("mode=manga") != -1) { var imageBoxes = document.getElementsByClassName("placeholder"); for (var i = imageBoxes.length - 1; i >= 0; --i) { var container = imageBoxes[i]; var imageUrl = /unshift\('([^']+)'\)/.exec(container.innerHTML)[1]; var image = container.getElementsByTagName("img")[0]; container.setAttribute("class", container.getAttribute("class").replace("placeholder", "")); image.setAttribute("src", imageUrl); } } }; // Removes text and image ads var RemoveAds = function() { var advertAreas = document.querySelectorAll('div.ads_area'); for (i = 0; i < advertAreas.length; ++i) advertAreas[i].parentNode.removeChild(advertAreas[i]); }; /// Add all functions that should be performed ImagesOpenDirectly(); LinksOpenInSameWindow(); PreloadMangaPages(); RemoveAds();