Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Bilibili SpamRemover
- // @namespace https://example.com/
- // @version 0.1
- // @description nil
- // @author -
- // @match *://*.bilibili.com/*
- // @run-at document-end
- // @grant unsafeWindow
- // ==/UserScript==
- function autoClickDialogs() {
- // Fix Dialog Problem.
- document.querySelector('body > div.v-dialog > div.v-dialog__wrap > div > div.v-dialog__body > div > div > span')?.click();
- document.querySelector('#app > div > div > div.natural-module > div.fixed-module > div.natural-main-video > div.main-info > div.btn')?.click();
- document.querySelector('body > div.v-dialog.natural-dialog > div.v-dialog__wrap > div > div.v-dialog__body > div > div.to-see')?.click();
- }
- function repairMobileCardBox() {
- // Fix CardItem Url;
- let cardBoxElement = document.getElementsByClassName('card-box')[0]?.children;
- if (cardBoxElement === undefined) { return };
- for (let cardItem of cardBoxElement) {
- if (cardItem.passed) { continue; }
- let bvid = cardItem?.__vue__?.$options?.propsData?.info?.bvid;
- if (!bvid) { continue; }
- let oldElement = cardItem;
- let newElement = oldElement.cloneNode(true);
- newElement.passed = true;
- newElement.onclick = () => {
- window.location = 'https://m.bilibili.com/video/' + bvid;
- };
- oldElement.parentNode.replaceChild(newElement, oldElement);
- }
- }
- function removeCardBoxOpenAppTags () {
- // Remove CardBoxOpenApp Tags.
- let cardBoxOpenAppTags = document.getElementsByClassName('open-app weakened');
- if (cardBoxOpenAppTags === undefined) { return; };
- for (let openAppTag of cardBoxOpenAppTags) {
- if (openAppTag.passed) { continue; }
- openAppTag.style.display = 'none';
- openAppTag.passed = true;
- }
- }
- function repairMobileTitleClick() {
- // Repair Title.
- let titleElement = document.getElementsByClassName('title-wrapper')[0];
- if (titleElement && !titleElement.passed) {
- let oldTitleElement = titleElement;
- let newTitleElement = oldTitleElement.cloneNode(true);
- newTitleElement.passed = true
- oldTitleElement.parentNode.replaceChild(newTitleElement, oldTitleElement);
- }
- }
- function repairComment() {
- // Enable Comments.
- let commentElement = document.querySelector('#comment');
- if (!commentElement) { return; }
- if (!commentElement.__vue__) { return; }
- if (!commentElement.__vue__.user) { return; }
- if (commentElement && !commentElement.__vue__.user.isLogin) {
- commentElement.__vue__.user.isLogin = true
- commentElement.__vue__.initComment();
- }
- }
- function processHandler() {
- autoClickDialogs();
- repairMobileCardBox();
- removeCardBoxOpenAppTags();
- repairMobileTitleClick();
- repairComment();
- }
- (function() {
- "use strict";
- setInterval(processHandler, 300);
- })();
- // Disable Click Spam Copy ExecCommand Event.
- unsafeWindow.document.execCommand = () => {};
- // Disable Click FullScreen Button Auto Download Application.
- let playerAgent = unsafeWindow.window?.PlayerAgent;
- if (playerAgent) {
- playerAgent.openApp = () => {};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement