Greasy Fork

Greasy Fork is available in English.

抖音免登录以及查看评论

关闭抖音登录面板及相关视频卡片登录引导

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         抖音免登录以及查看评论
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  关闭抖音登录面板及相关视频卡片登录引导
// @author       wj
// @match        https://www.douyin.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
  "use strict";

  // Function to check for the login panel and close it
  function checkAndCloseLoginPanel() {
    // Find divs with id containing 'login-full-panel-'
    var loginPanelDivs = document.querySelectorAll(
      'div[id*="login-full-panel-"]'
    );
    if (loginPanelDivs.length > 0) {
      // Find the div with class 'dy-account-close'
      var closeButton = document.querySelector("div.dy-account-close");
      if (closeButton) {
        // Click the close button
        closeButton.click();
        console.log("登录面板已关闭");
      }
    }
  }

  // Function to check for the related video card login guide and close it
  function checkAndCloseRelatedVideoCardLoginGuide() {
    // Find the div with id 'related-video-card-login-guide'
    var relatedVideoCardLoginGuide = document.getElementById(
      "related-video-card-login-guide"
    );
    if (relatedVideoCardLoginGuide) {
      // Find the close button within the related video card login guide footer
      var closeButton = relatedVideoCardLoginGuide.querySelector(
        "div.related-video-card-login-guide__footer div.related-video-card-login-guide__footer-close"
      );
      if (closeButton) {
        // Click the close button
        closeButton.click();
        console.log("相关视频卡片登录引导已关闭");
      }
    }
  }

  // Check and close login panels on DOM content loaded
  document.addEventListener("DOMContentLoaded", function () {
    checkAndCloseLoginPanel();
    checkAndCloseRelatedVideoCardLoginGuide();
  });

  // Additionally, observe the DOM for changes and check again if necessary
  var observer = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
      checkAndCloseLoginPanel();
      checkAndCloseRelatedVideoCardLoginGuide();
    });
  });

  // Configure the observer to watch for changes in the body subtree
  observer.observe(document.body, { childList: true, subtree: true });
})();