Greasy Fork

Greasy Fork is available in English.

冲浪助手

让web页面更加容易浏览、操作

当前为 2023-02-15 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         冲浪助手
// @namespace    https://github.com/Shadow-blank/net-tools
// @version      0.1.2
// @description  让web页面更加容易浏览、操作
// @author       Shadow-blank
// @match        *://m.weibo.cn/status/*
// @match        *://www.comicat.org/*
// @match        *://2.comicat.net/*
// @match        *://3.comicat.net/*
// @match        *://dick.xfani.com/*
// @match        *://live.bilibili.com/*
// @match        *://www.bilibili.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=weibo.cn
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict'

  // 微博移动端自动跳转到PC
  const weiboMJump2PC = () => {
    setTimeout(() => {
      const userId = document.querySelector('.m-img-box').href.split('/')[4]
      const id = location.pathname.split('/')[2]
      location.href = `https://weibo.com/${userId}/${id}`
    }, 500)
  }

  // 漫猫将下载按钮位置上升
  const comicatMoveDown = () => {
    const downEle = document.querySelector('#box_download')
    downEle.parentElement.insertBefore(downEle, downEle.parentElement.firstElementChild)
  }

  // 稀饭取消右键限制
  const xfaniRventMenu = () => {
    ['contextmenu', 'click', 'mousedown', 'mouseup', 'selectstart'].forEach(item => clearEvent(item))
    function clearEvent (type) {
      const onType = 'on' + type
      document[onType] = null
      document.body && (document.body[onType] = null)
    }
  }

  // bilibili去除首页轮播图 只保留番剧和推荐
  const bilibiliRomoveBanner = () => {
    // 取消bilibili默认样式
    const style = document.createElement('style')
    style.innerHTML = `
     .bili-video-card.is-rcmd{
        display: block!important; 
     }
     .recommended-swipe, .eva-extension-area, .battle-area, .live-card-list, .live-rank-conent, .video-card-list, .bili-grid:nth-child(n+10), .eva-banner{
        display: none!important; 
     }`
    document.querySelector('body').appendChild(style)
    // 去除轮播图
  }

  // 直播页面去掉广告 只显示直播
  const biliLiveRmoveOther = () => {
    let timer = ''
    // 推广直播页面进入原始页面
    timer = setInterval(() => {
      const iframe = document.querySelector('#app iframe')
      if (iframe?.src.includes('/blanc/')) {
        clearInterval(timer)
        location.href = iframe.src.split('?')[0]
      }
    }, 100)
    // 将直播画面居中显示
    document.querySelector('.live-room-app.p-relative').style.overflow = 'hidden'
    document.querySelector('main').style.padding = '0px'
    document.querySelector('.player-ctnr.left-container.p-relative.z-player-ctnr').style = 'width: 100%; margin: 10px auto'
    document.querySelector('#iframe-popup-area').remove()
    document.querySelector('section').style.margin = '0px'
  }

  const host = location.host

  const hostMap = {
    'm.weibo.cn': weiboMJump2PC,
    '2.comicat.net': comicatMoveDown,
    '3.comicat.net': comicatMoveDown,
    'dick.xfani.com': xfaniRventMenu,
    'www.bilibili.com': bilibiliRomoveBanner,
    'live.bilibili.com': biliLiveRmoveOther
  }

  hostMap[host] && hostMap[host]()

})()