Soul+Linker

用于从魂+快速跳转到DLsite

Verze ze dne 21. 04. 2022. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         Soul+Linker
// @name:en         Soul+Linker
// @name:zh         Soul+Linker
// @namespace    [email protected]
// @version      1.2.3
// @description  用于从魂+快速跳转到DLsite
// @description:en  Used to jump from Soul+ to DLsite quickly
// @description:zh  用于从魂+快速跳转到DLsite
// @author       Xiccnd

// @license      GPL-3.0 License

// @include        *://white-plus.net/*
// @include        *://snow-plus.net/*
// @include        *://level-plus.net/*
// @include        *://east-plus.net/*
// @include        *://south-plus.net/*
// @include        *://north-plus.net/*
// @include        *://spring-plus.net/*
// @include        *://summer-plus.net/*
// @include        *://imoutolove.me/*

// @include        *://www.white-plus.net/*
// @include        *://www.snow-plus.net/*
// @include        *://www.level-plus.net/*
// @include        *://www.east-plus.net/*
// @include        *://www.south-plus.net/*
// @include        *://www.north-plus.net/*
// @include        *://www.spring-plus.net/*
// @include        *://www.summer-plus.net/*
// @include        *://bbs.imoutolove.me/*

// @exclude        *://www.white-plus.net/index.php
// @exclude        *://www.snow-plus.net/index.php
// @exclude        *://www.level-plus.net/index.php
// @exclude        *://www.east-plus.net/index.php
// @exclude        *://www.south-plus.net/index.php
// @exclude        *://www.north-plus.net/index.php
// @exclude        *://www.spring-plus.net/index.php
// @exclude        *://www.summer-plus.net/index.php
// @exclude        *://bbs.imoutolove.me/index.php

// @exclude        *://www.white-plus.net/
// @exclude        *://www.snow-plus.net/
// @exclude        *://www.level-plus.ne/
// @exclude        *://www.east-plus.net/
// @exclude        *://www.south-plus.net/
// @exclude        *://www.north-plus.net/
// @exclude        *://www.spring-plus.net/
// @exclude        *://www.summer-plus.net/
// @exclude        *://bbs.imoutolove.me/

// @exclude        *://white-plus.net/index.php
// @exclude        *://snow-plus.net/index.php
// @exclude        *://level-plus.net/index.php
// @exclude        *://east-plus.net/index.php
// @exclude        *://south-plus.net/index.php
// @exclude        *://north-plus.net/index.php
// @exclude        *://spring-plus.net/index.php
// @exclude        *://summer-plus.net/index.php
// @exclude        *://imoutolove.me/index.php

// @exclude        *://white-plus.net/
// @exclude        *://snow-plus.net/
// @exclude        *://level-plus.ne/
// @exclude        *://east-plus.net/
// @exclude        *://south-plus.net/
// @exclude        *://north-plus.net/
// @exclude        *://spring-plus.net/
// @exclude        *://summer-plus.net/
// @exclude        *://imoutolove.me/

// @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @icon         https://cdn.jsdelivr.net/gh/Xiccnd/Xiccnd-Pic@master/20220421113011992.1vh7zbll47r4.ico
// @grant        none
// ==/UserScript==

$(function () {

    'use strict';

    /*
    * 设置全局变量,开头加前缀避免重名
    * */
    //获取标题
    const XICCND_TITLE = $('h1#subject_tpc.fl').html();
    //设置检查规则
    const XICCND_CHECK_RJ = new RegExp('RJ[0-9]{6}');

    /*
    * 开关插件功能
    * */

    //开启跳转功能
    xiccndRJ()

    //开启图片预览功能
    xiccndRJImg()

    //开启网站清爽模式,建议配合Soul+Cleaner和Soul++图墙自动打开一起使用
    //xiccndCleanMode()

    //开启去除文章广告,会导致无法列表模式观看,建议图墙用户开启
    //xiccndCleanList()

    /*
    * 跳转
    * */
    function xiccndRJ() {

        /*
        * 检查标题是否含有RJ号
        * */
        if (XICCND_CHECK_RJ.test(XICCND_TITLE)) {//如果含有
            //获取RJ号
            const XICCND_RJ = XICCND_TITLE.substr(XICCND_TITLE.indexOf("RJ"), 8)
            $("h1#subject_tpc.fl").on('mouseover', function () {//鼠标悬停效果
                $(this).css('cursor', 'pointer').css('color', 'pink')
            }).on('mouseout', function () {//鼠标离开效果
                $(this).css('color', '#bbbbbb')
            }).on('click', function () {//鼠标点击效果
                window.open("https://www.dlsite.com/maniax/work/=/product_id/" + XICCND_RJ + ".html");//跳转网页
            })
        } else {//如果不含有
            //生成跳转表单
            const SEARCHBAR = '<input id="xiccndSearchbar" type="text" value="RJ" placeholder="请输入RJ号" style="width: 100px; height: 20px; margin-left: 5px"/>'
            const BUTTON = '<input id="xiccndSearchbarButton" type="submit" value="跳转" style="height: 25px; margin-left: 5px"/>'
            const FORM = '<form id="xiccndSearchForm" action="" style="display: none">' + SEARCHBAR + BUTTON + '</form>'
            //添加生成表单
            $('div.h1.fl').append(FORM)

            $("h1#subject_tpc.fl").on('click', function () {
                //标题点击效果
                $('form#xiccndSearchForm').stop().toggle(500)
                //跳转按钮效果
                $('input#xiccndSearchbarButton').on('mouseover', function () {
                    $(this).css('cursor', 'pointer')
                }).on('click', function () {
                    const SEARCH_RJ = $('input#xiccndSearchbar').val()

                    if (SEARCH_RJ === "") {//内容为空时
                        alert('RJ号为空,请重新输入!')
                        return false
                    } else if (XICCND_CHECK_RJ.test(SEARCH_RJ)) {//RJ号格式规范时
                        $('form#xiccndSearchForm').attr('action', 'https://www.dlsite.com/maniax/work/=/product_id/' + SEARCH_RJ + '.html')
                        return true
                    } else {//RJ号格式不规范时
                        alert('RJ号不规范,请重新输入!')
                        return false
                    }
                })
            }).on('mouseover', function () {
                $(this).css('cursor', 'pointer').css('color', 'plum')
            }).on('mouseout', function () {
                $(this).css('color', '#bbbbbb')
            })
        }
    }

    /*
    * 图片预览
    * */
    function xiccndRJImg() {
        if (XICCND_CHECK_RJ.test(XICCND_TITLE)) {//检查标题是否含有RJ号
            //获取RJ号
            const XICCND_RJ = XICCND_TITLE.substr(XICCND_TITLE.indexOf("RJ"), 8)

            //合成路径
            let RJPre = XICCND_RJ.substr(0, 4)
            let RJBody = parseInt(XICCND_RJ.substr(4, 1)) + 1

            if (RJBody === 10) {//当RJBody为9时,RJBody要变为0,前一个数字加1
                RJPre = RJPre.substr(0, 3) + (parseInt(RJPre.substr(3, 1)) + 1)
                RJBody = 0
            }

            const RJSRC = RJPre + RJBody + '000'
            //合成图片地址
            const SRC = '//img.dlsite.jp/modpub/images2/work/doujin/' + RJSRC + '/' + XICCND_RJ + '_img_main.jpg'
            //创建图片
            const IMG = '<img id="xiccndImg" style="display: none; width: 15%; position: fixed; left: 1%;top: 10px;border: 5px dashed pink" alt="' + XICCND_TITLE + '" src= ' + '"' + SRC + '"' + '>'
            //网页中添加图片
            $('body').append(IMG)

            $("h1#subject_tpc.fl").on('mouseover', function () {
                $(this).css('cursor', 'pointer').css('color', 'pink')
                $('img#xiccndImg').stop().fadeIn(1000)
            }).on('mouseout', function () {
                $(this).css('color', '#bbbbbb')
                $('img#xiccndImg').stop().fadeOut(1000)
            })
        }
    }

    /*
    * 网站清爽模式
    * */
    function xiccndCleanMode() {

        /*
        * 去除页头广告
        * */
        $('div#header div').eq(-2).remove()

        /*
        * 去除网页头部
        * */
        $('td.banner').remove()

        /*
        * 去除网页底部
        * */
        $('div#main>div.t_one').remove()
        $('div#footer').remove()

        /*
        * 去除公告
        * */
        $('div.gonggao').remove()
    }

    /*
    * 去除文章广告
    * */
    function xiccndCleanList() {
        $('table#ajaxtable>tbody').eq(1).remove()
    }

})