// ==UserScript== // @name 斗鱼直播间播放器置顶 // @license GPL-3.0 License // @namespace https://greasyfork.org/zh-CN/scripts/399600-%E6%96%97%E9%B1%BC%E7%9B%B4%E6%92%AD%E9%97%B4%E6%92%AD%E6%94%BE%E5%99%A8%E7%BD%AE%E9%A1%B6 // @version 0.60 // @description 需与 sylus【[夜间斗鱼](https://userstyles.world/style/240/nightmode-for-douyu-com) NightMode For Douyu.com】 配合使用,可屏蔽除播放器外所有元素。 // @author QIUZAIYOU // @match *://*.douyu.com/0* // @match *://*.douyu.com/1* // @match *://*.douyu.com/2* // @match *://*.douyu.com/3* // @match *://*.douyu.com/4* // @match *://*.douyu.com/5* // @match *://*.douyu.com/6* // @match *://*.douyu.com/7* // @match *://*.douyu.com/8* // @match *://*.douyu.com/9* // @match *://*.douyu.com/topic/* // @match *://*.douyu.com/directory/myFollow // @require https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js // @require https://cdn.jsdelivr.net/npm/sweetalert2@11.3.6/dist/sweetalert2.all.min.js // @resource swalStyle https://cdn.jsdelivr.net/npm/sweetalert2@11.3.6/dist/sweetalert2.min.css // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_getResourceText // @grant GM.info // @supportURL https://github.com/QIUZAIYOU/Douyu-Player-StickyTop // @homepageURL https://github.com/QIUZAIYOU/Douyu-Player-StickyTop // @downloadURL none // ==/UserScript== //【NightMode For Douyu.com 夜间斗鱼:https://userstyles.org/styles/158117 $(function () { let util = { getValue (name) { return GM_getValue(name); }, setValue (name, value) { GM_setValue(name, value); }, exist (selecter) { return Boolean($(selecter).length >= 1) }, sleep (time) { return new Promise((resolve) => setTimeout(resolve, time)); }, addStyle (id, tag, css) { tag = tag || 'style'; let doc = document, styleDom = doc.getElementById(id); if (styleDom) return; let style = doc.createElement(tag); style.rel = 'stylesheet'; style.id = id; tag === 'style' ? style.innerHTML = css : style.href = css; document.head.appendChild(style); }, }; let main = { initValue () { let value = [{ name: 'current_screen_mod', value: 'normal' }, { name: 'selected_screen_mod', value: 'webfullscreen' }, { name: 'auto_web_full_screen', value: true }, { name: 'auto_select_video_highest_quality', value: true }, { name: 'auto_select_danmu_options', value: true }, { name: 'auto_block_gift_effect', value: true }]; value.forEach((v) => { if (util.getValue(v.name) === undefined) { util.setValue(v.name, v.value); } }); }, playerStickyTop () { $("body").prepend($("header")); $(".layout-Player").attr("id", "layout-Player").css({ "width": "1400px", "margin": "0 auto", "margin-top": "80px" }); $("header").after($("#layout-Player")); }, fixedAside () { let url = $(location).attr('href'); let room = /https:\/\/www.douyu.com\/\d+/i; if (room.test(url)) { $("header").after($("#js-aside")); $("header").after($("#js-aside-state")); } else { return false; } }, getCurrentScreenMod () { let mutationObserver = new MutationObserver(() => { let bodyClass = $("body").attr("class") || 'normal'; if (bodyClass.includes('is-fullScreenPage')) { util.setValue('current_screen_mod', 'webfullscreen') } else { util.setValue('current_screen_mod', 'normal') } }); mutationObserver.observe($("body")[0], { attributes: true, }); }, autoSelectScreenMod () { let selected_screen_mod = util.getValue('selected_screen_mod') if (selected_screen_mod) { let current_screen_mod = util.getValue('current_screen_mod'); let selected_screen_mod = util.getValue('selected_screen_mod'); let openWebFullScreenButton = $("[title='网页全屏'][class*='wfs']"); if (selected_screen_mod === 'webfullscreen' && current_screen_mod !== 'webfullscreen') { openWebFullScreenButton.click(); // console.log("screen done") } } }, autoSelectVideoHightestQuality () { let auto_select_video_highest_quality = util.getValue('auto_select_video_highest_quality'); let hightestQualityButton = $('[class*="rate"] > [class*="tip"] > ul > li').eq(0); let hightestQualityButtonClass = hightestQualityButton.attr('class') || 'normal'; if (auto_select_video_highest_quality && !hightestQualityButtonClass.includes('selected')) { hightestQualityButton.click(); // console.log("quality done") } }, autoBlockGiftEffect () { const auto_block_gift_effect = util.getValue('auto_block_gift_effect'); if (auto_block_gift_effect) { $('.ShieldTool-content .ShieldTool-enter .ShieldTool-list > div.ShieldTool-listItem').each(function () { const checkState = $(this).attr('class') if (checkState.includes('is-noChecked')) { $(this).click() } }) } }, autoSelectDanmuOptions () { let auto_select_danmu_options = util.getValue('auto_select_danmu_options') if (auto_select_danmu_options) { $(".noMcsettingPanel-697312 .iconBtn-70d178").each(function () { let styleCont = $(this).attr("style"); let labelColor = $(this).children("label").attr("style"); let imgList = ['quarterscreen_84589b', 'bigforbid_5d2d1c', 'topforbid_f08785', 'bottomforbid_9b3f00', 'roleforbid_08998e']; for (let i = 0; i < imgList.length; i++) { if (styleCont.includes(imgList[i]) & labelColor.includes("204")) { $(this).children("label").click() } } $(".simpleDanmu-a83422 span.icon-d798db + label.simpleLabel-c5c1e1").click() }); // console.log("danmu done") } main.autoBlockGiftEffect() }, registerMenuCommand () { GM_registerMenuCommand('设置', () => { let html = `