Greasy Fork

Greasy Fork is available in English.

douyin-mobile-web

douyin mobile web

目前为 2023-10-16 提交的版本。查看 最新版本

// ==UserScript==
// @name         douyin-mobile-web
// @description  douyin mobile web
// @version      1.2.0
// @match       https://www.douyin.com/
// @match        https://live.douyin.com/*
// @namespace   https://trim21.me/
// @grant        GM_addStyle
// @license MIT
// ==/UserScript==

(function () {
    "use strict";

    // 添加 CSS 样式
    GM_addStyle(`
    /* 展开评论后评论宽高及位置 */
    #videoSideBar {
        position: absolute;
        left: 0;
        width: 100%;
        height: 61%;
        top: 39%;
    }
    #relatedVideoCard {
        margin-top: 1vh;
        height: 95%
    }
    .mQjJJImN._8RdwESC {
        line-height: 1.2!important
    }
    .mQjJJImN._8RdwESC * {
        line-height: inherit!important;
    }
    .comment-input-container {
        display: none
    }
    .comment-reply-expand-btn {
        height: auto!important
    }
    .comment-item-stats-container {
        height: auto!important
    }
    .comment-item-tag {
        height: auto!important
    }
    /*评论区登录提示删除*/
    #related-video-card-login-guide {
        display: none
    }
    .T3p4lV8L {
        filter: none!important
    }
    .IXR56A9B {
        width: 144px!important;
        height: 144px!important;
        position: relative!important;
        top: 144px!important;
    }
    .ojlTaq_K {
        width: 100%!important;
        height: 100%!important;
    }
    /*评论区表情包大小*/
    .jZ9bChTp {
        height: 1em!important;
        width: 1em!important;
    }
    .avatar-component-avatar-container {
        height: 1em!important;
        width: 1em!important;
    }
    /*右侧工具栏头像大小*/
    .F55pZYYH.zzYG7dwz.avatar-component-avatar-container.pXlwVyyi {
        height: 6rem!important;
        width: 6rem!important;
    }
    .YTu_A7CW.bx6jfq7y.xfVAG0BN {
        transform: scale(0.5)!important;
    }
    /* 展开评论后视频高度及位置 */
    .WQ9IVUcw {
        height: 39%;
        top: 0%
    }
    /*TA的作品字体*/
    .author-card-user-name {
        height: auto!important;
    }
    .Nu66P_ba.MDEPW30B {
        max-width: unset!important;
        line-height: 1!important;
        height: auto!important;
    }
    .author-card-user-stats {
        height: auto!important;
    }
    .B3AsdZT9.Onp3QgDp {
        height: auto!important;
    }
    .author-card-follow-btn {
        height: auto!important;
    }
    /*播放器进度粗细*/
    /* 视频宽度 */
    .playerContainer {
        width: 100% !important;
    }
    /*视频点击高亮框去除*/
    .xgplayer {
        cursor: unset
    }
    /* 播放器高度 */
    .xg-video-container {
        height: 100%
    }
    /* 视频标题宽度 */
    .tSXOCvQc {
        bottom: 5vh!important
    }
    .video-info-detail {
        padding-right: 15%!important;
        opacity: 0.5;
    }
    .video-info-mask {
        display: none
    }
    /*标题作者名*/
    #video-info-wrap div.account-name {
        max-width: 80vw!important
    }
    /*相关搜索*/
    .Fgy_mWbW.dySwiperSlide .PeKH830H.RUCJaKbm {
        font-size: 0.5em!important;
    }
    .Fgy_mWbW.dySwiperSlide .PeKH830H.RUCJaKbm * {
        font-size: 1.5em!important;
    }
    .PeKH830H.RUCJaKbm {
        height: 1.5em!important;
    }
    .s0w6Jo4w .VzED0RH9 {
        height: 1.5em!important;
    }
    .s0w6Jo4w .VzED0RH9 .PeKH830H .EQrV9Oyh {
        line-height: 1.5em!important;
        max-width: unset
    }
    /* 视频功能按钮宽度 */
    .xg-inner-controls {
        height: 5vh!important;
    }
    .xgplayer-icon {
        height: auto!important;
    }
    .xg-left-grid {
        margin-right: 0!important;
    }

    xg-icon {
        width: auto!important
    }
    div > div.btn {
        width: 100px!important
    }
    .xgplayer-playback-setting {
        display: none
    }
    .xgplayer-playclarity-setting {
        display: none!important;
        width: 100px!important
    }
    .xgplayer-immersive-switch-setting {
        display: none!important
    }
    svg {
        width: 1.5em;
        height: 1.5em
    }

    /*展开按钮样式*/
    .npIvCX5K:before {
        height: calc(100% - var(--lineHeight) - 1.2vh)
    }
    ._f3D05pF {
        width: auto!important;
        line-height: 0!important
    }
    /* 视频和评论整体字体大小... */
    .Fgy_mWbW.dySwiperSlide {
        font-size: 3vh!important
    }
    .Fgy_mWbW.dySwiperSlide * {
        font-size: inherit!important;
    }
    /* 视频竖版功能按钮宽度 */
    .OFZHdvpl.immersive-player-switch-on-hide-interaction-area {
        font-size: 1vh!important
    }
    .L1TH4HdO.immersive-player-switch-on-hide-interaction-area {
        font-size: 1vh!important
    }
    .xgplayer-playswitch {
        display: none
    }
    /*去掉登录弹窗*/
    .mPWahmAI.screen-mask.login-mask-enter-done {
        display: none
    }
    .JsAsIOEV {
        display: none
    }
    .cL3t_Mk2 {
        display: none
    }
    /*删除上下滚动视频提示图片*/
    .I6ivXmaS {
        display: none;
    }
    /*删除验证码图片#captcha_container*/
    .c1aptcha_verify_container {
        width: 100vw !important;
        font-size: 3vh!important
    }
    .c1aptcha_verify_container * {
        font-size: inherit!important;
    }
    .c1aptcha_verify_img--wrapper {
        width: 95.2vw!important;
        height: 59.36vw!important;
    }
    /*删除关闭按钮*/
    .verify-bar-close--icon {
        height: 3vh!important;
        width: 3vh!important;
    }
    .captcha_verify_bar--close {
        right: 3vh!important;
    }
    /*验证码下方工具条宽高*/
    .captcha_verify_action.sc-jDwBTQ.dhdXHN div.sc-gPEVay.hdkDPH {
        line-height: initial;
    }
    .verify-captcha-submit-button {
        width: 7vh!important;
        height: 4vh!important;
        line-height: 4vh!important;
    }

    /*页面https://www.douyin.com/user/*/
    /*关闭水平滚动*/
    ._bEYe5zo {
        overflow-y: unset!important;
    }
    /*搜索框*/
    .AFTy15pW {
        width: 100vw!important;
    }
    .lPytbapz {
        margin: 0 auto;
        width: 50%!important;
    }
    /*侧边栏*/
    div.N_HNXA04.KYtgzo9m {
        display: none
    }
    /*头部右侧图标*/
    .iqHX00br {
        display: none
    }
    /*个人简介*/
    .wTV10cVL {
        height: auto!important;
        flex-wrap: wrap
    }
    .eDwMD7wB {
        height: auto!important;
        flex-wrap: wrap
    }
    /*关注私信等按钮*/
    ._7gdyuNUv {
        display: none!important
    }
    /*个人介绍的更多按钮不缩进*/
    .i5w9Y0wZ {
        flex-shrink: 0
    }

    /*整体字体大小*/
    ._LDrC7Wb.Smb5gBZJ {
        font-size: 2vh!important;
        line-height: 3vh!important;

        width: 100vw!important;
        margin: 0
    }
    ._LDrC7Wb.Smb5gBZJ * {
        font-size: inherit!important;
        line-height: inherit!important;
    }

    /*整体瀑布流排版*/
    .EZC0YBrG.Nfs9sicY {
        display: flex;
        flex-wrap: wrap;
    }

    .Eie04v01._Vm86aQ7.PISbKxf7 {
        flex: 0 0 calc(50% - 10px);

        margin: 5px;
    }
    /*视频文案*/
    .__0w4MvO {
        height: auto !important;
    }

    div.F55pZYYH.QsTz7P83.avatar-component-avatar-container.lXUK6YKh.NyjpXQks {
        width: auto !important;
        height: auto !important
    }
    /*他的主页*/
    /*字体*/
    .mPWahmAI.Rdkm80SF {
        font-size: 3vh!important
    }
    .mPWahmAI.Rdkm80SF * {
        font-size: inherit!important;
    }
    /* 视频竖版功能按钮宽度 */
    .OFZHdvpl.immersive-player-switch-on-hide-interaction-area {
        font-size: 1vh!important
    }
    /*TA的作品*/
    .xgplayer-inner-autoplay.automatic-continuous {
        font-size: 0!important;
    }
    .xgplayer-inner-autoplay.automatic-continuous * {
        font-size: 0!important;
    }
    .xgplayer-inner-autoplay.automatic-continuous svg {
        font-size: 40px!important;
    }
    .xgnFsawv.gk3ariuU .rrDv0xv4 svg {
        height: 2em!important;
        width: 2em!important;
    }
    .xgnFsawv .rrDv0xv4 {
        height: auto;
        margin-top: 0
    }
    .xgnFsawv.gk3ariuU .b_o0jOiZ {
        height: auto;
        top: -300px;
    }
    /*直播*/
    .tGBLU2eM.CesTJB9J {
        display: none
    }
    div[data-index="30"] {
        display: none
    }
    xg-icon[data-index="15"] {
        display: none
    }
    xg-icon[data-index="0.7"] {
        display: none
    }
    div[data-index="12"] {
        height: 32px!important
    }
    .sZpq_8QT .mC7Tdutu {
        display: none
    }
    .vBglP_gH .xg-inner-controls.xg-pos {
        flex-direction: column-reverse;
    }
    .xg-top-bar {
        flex-direction: column;
    }
    .tGBLU2eM.uLi3I6pi {
        margin: 0!important
    }
    .tGBLU2eM.bNdDEy7b {
        margin: 0!important
    }
      `);
    function waitForElementAndClick(selector, interval, maxAttempts) {
        let attempts = 0;

        function checkAndClick() {
            const element = document.querySelector(selector);

            if (element) {
                element.click();
                console.log(selector, 'Element found and clicked.');
            } else {
                attempts++;
                if (attempts < maxAttempts) {
                    console.log(selector, 'Element not found. Retrying in ' + interval + 'ms...');
                    setTimeout(checkAndClick, interval);
                } else {
                    console.log('Max attempts reached.' + selector, +' Element not found.');
                }
            }
        }

        checkAndClick();
    }

    // 使用示例
    if (window.location.hostname === 'live.douyin.com')
        return waitForElementAndClick('.xgplayer-fullscreen', 1000, 10);

    waitForElementAndClick('.xgplayer-page-full-screen > div.xgplayer-icon', 1000, 10);

})();