Wallhaven 壁紙網站增強

Wallhaven 是最酷的壁紙網站,本腳本為該網站提供了額外的功能,能讓妳更暢快的尋找到喜歡的圖片。

目前為 2017-05-03 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                Wallhaven Enhance
// @name:zh-CN          Wallhaven 壁纸网站增强
// @name:zh-TW          Wallhaven 壁紙網站增強
// @description         The script for the coolest wallpaper site provides additional features, can make you more fun to find favorite pictures.
// @description:zh-CN   Wallhaven 是最酷的壁纸网站,本脚本为该网站提供了额外的功能,能让你更畅快的寻找到喜欢的图片。
// @description:zh-TW   Wallhaven 是最酷的壁紙網站,本腳本為該網站提供了額外的功能,能讓妳更暢快的尋找到喜歡的圖片。

// @author              Moshel
// @namespace           https://hzy.pw
// @homepageURL         https://hzy.pw/
// @supportURL          https://github.com/h2y/link-fix
// @icon                https://alpha.wallhaven.cc/favicon.ico
// @license             GPL-3.0

// @include             https://alpha.wallhaven.cc/search?*
// @include             https://alpha.wallhaven.cc/latest
// @grant               none
// @run-at              document-end

// @date                05/02/2017
// @modified            05/03/2017
// @version             1.0.0
// ==/UserScript==


{
    const hidePicsWithoutFavs = 10;
    
    
    // disable hide by favs in some page
    let enableHideByfavs = true;
    if(location.pathname == '/latest' || location.search.indexOf('sorting=relevance')>0)
        enableHideByfavs = false;
    else if(location.search.indexOf('sorting=date_added')>0 && location.search.indexOf('order=desc')>0)
        enableHideByfavs = false;
    else if(location.search.indexOf('sorting=views')>0)
        enableHideByfavs = false;
        
    
    let scanedPages = 0;
    
    
    main();
    function main() {
        const $pages = $('#thumbs > section');
        if($pages.length != scanedPages) {
            scanPics( $pages[scanedPages++] );
        }
        
        setTimeout(main, 2345);
    }
    
    
    function scanPics(scanInDom) {
        const $pics = $(scanInDom).find('li');
        
        for(let i=0; i<$pics.length; i++) {
            const $pic = $( $pics[i] );
            
            //get the pic id
            const picId = $pic.find('figure').data('wallpaper-id');
            
            //hide by favs 
            if(enableHideByfavs) {
                const $favs = $pic.find('.wall-favs'),
                    favs = parseInt($favs[0].innerHTML);
                if(favs < hidePicsWithoutFavs)
                    $pic.animate({opacity:.2}, 'fast');
            }
            
            //create download button
            $pic.find('.thumb-info').append(`<a class="jsDownload" href="https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-${picId}.jpg" download>
                <i class="fa fa-fw fa-cloud-download"></i>
                </a>`);
        }
    }
    
} //end userScript