Auto Try Big Image

Automatically try to show big image instead of original preview.

目前為 2017-02-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Auto Try Big Image
// @namespace   mnts
// @description Automatically try to show big image instead of original preview.
// @include     http://anime-pictures.net?*
// @include     *://*anime-pictures.*/*
// @include     http?://anime.reactor.cc/tag/?*
// @include     *://*anime.reactor.*/tag/*
// @include     http?://zerochan.net/?*
// @include     *://*zerochan.*/*
// @include     http?://otakumode.com/?*/post/?*
// @include     *://*otakumode.*/*/post/*
// @version     1.0
// @grant       none
// ==/UserScript==

function tryAnimePictures() { //anime-pictures.net
    var aPreview = document.getElementById('big_preview_cont').getElementsByTagName('a')[0];
    if (aPreview === undefined) return;
    var bigImgUrl = aPreview.getAttribute('href');
    if (bigImgUrl !== undefined && bigImgUrl !== "") {
        var imgPreview = aPreview.getElementsByTagName('img')[0];
        if (imgPreview === undefined) return;
        imgPreview.setAttribute('width', imgPreview.width);
        imgPreview.setAttribute('src', '');
        imgPreview.setAttribute('src', bigImgUrl);
    }
}

function tryAnimeReactorCC() {
    var asPreview = document.getElementsByClassName('prettyPhotoLink');
    for (var i = 0; i < asPreview.length; i++) {
        var a = asPreview[i];
        var urlBigImg = a.getAttribute('href');
        var img = a.getElementsByTagName('img')[0];
        img.setAttribute('src', '');
        img.setAttribute('src', urlBigImg);
    }
}

function tryZerochan() {
    var divPreview = document.getElementById('large');
    if (divPreview === undefined) return;
    var aPreview = divPreview.getElementsByTagName('a')[0];
    if (aPreview === undefined) return;
    var imgPreview = aPreview.getElementsByTagName('img')[0];
    if (imgPreview === undefined) return;
    var urlFull = aPreview.getAttribute('href');
    if (urlFull.length <= 0) return;
    imgPreview.setAttribute('src', '');
    imgPreview.setAttribute('src', urlFull);
}

function tryOtakumode() {
    var countPreview = 0;
    //var divContents = document.getElementById('contents');
    var articlesPreview = document.getElementsByTagName('article');
    //if (articlesPreview === undefined) return;
    var articlePreview = articlesPreview[0];

    articlePreview.addEventListener('DOMSubtreeModified', function() {
        console.log('gotcher');
        var imgsPreview = document.getElementsByClassName('first nomenu nodraggable');
        if (countPreview === imgsPreview.length) return;
        countPreview = imgsPreview.length;
        console.log('atari');

        var exprPass = ".*x\.jpg$";
        for (var i = 0; i < imgsPreview.length; i++) {
            var imgPreview = imgsPreview[i];
            var urlImage = imgPreview.getAttribute('src');
            if (urlImage.match(exprPass) === null) {
                console.log('bingo');
                var ext = '.jpg';
                var urlImageBig = urlImage.substring(0, urlImage.length - ext.length) + 'x' + urlImage.substring(urlImage.length - ext.length);
                imgPreview.setAttribute('src', '');
                imgPreview.setAttribute('src', urlImageBig);
            }
        }
    });
}

tryAnimePictures();
tryAnimeReactorCC();
tryZerochan();
tryOtakumode();