Skip to content

Commit

Permalink
Dev (#786)
Browse files Browse the repository at this point in the history
* 深色新增搜索页,所有框线改为亮色,修复大量问题

* 文案更新

* 修复关闭版聊时不会重新显示弹幕区的错误

* 修复主页分区屏蔽在特定情况下失效的BUG (#785)

* 添加名为home的kind,作用于B站主页

* Feature:添加主页分区屏蔽功能

* fix: 修复Feature在other下时,subPage找不到map的bug

* Dev (#780)

* 深色新增搜索页,所有框线改为亮色,修复大量问题

* 文案更新

* 修复关闭版聊时不会重新显示弹幕区的错误

* 版聊模式隐藏右侧边栏逻辑恢复

* 删除去污粉用户等级选项 & 增加eslint规则

* 调整版聊模式逻辑

* Feature: 添加屏蔽主页分区的功能 (#778)

* 添加名为home的kind,作用于B站主页

* Feature:添加主页分区屏蔽功能

* fix: 修复Feature在other下时,subPage找不到map的bug

* clean up code

* 移除pages/config/_locales中home相关部分

* 添加美食区屏蔽开关

* 添加美食区屏蔽开关 (#781)

* 移除pages/config/_locales中home相关部分

* 添加美食区屏蔽开关

* fix:浏览器兼容性修复

在edge中bilibili实际使用语言与插件识别语言不同的临时解决方案;
修复在部分浏览器下,由于该模块与b站主页分区异步加载导致插件实际失效的bug

* 增加语言主动选择 & 增加uid统计选项

* 去掉了对language模块的依赖 & 调整i18n工具函数默认逻辑

* 替换屏蔽分区模块中错误的key

* 修复首页屏蔽bug

* 具有人文关怀的视频页独立深色

* 视频深色按钮还原到锚点加载

* 修复部分深色模式的问题

* 修复去污粉无法屏蔽舰长消息的bug

* 调整深色模式 播放页 接下来播放 .next-play 的颜色 (#793)

并不是添加新的样式,而是仅使用 .card-box 选择了所有的视频卡片,将 .next-play 下的 .card-box 也包含在内。

* 修复pip,弹幕特殊字符问题,视频下载问题

* 修复部分用户无法下载视频的问题
  • Loading branch information
jjj201200 committed Nov 26, 2020
1 parent 152ec0c commit 20ab28f
Show file tree
Hide file tree
Showing 29 changed files with 221 additions and 143 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bilibili-helper-master",
"version": "1.2.25-beta.1",
"version": "1.2.25-beta.2",
"description": "bilibili-helper",
"main": "index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/chatFilter/UI/ChatFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default () => {
constructor(props) {
super(props);
this.styleList = {
chat: '.chat-item:not(.hover).danmaku-item{display:none;}',
chat: '.chat-item:not(.hover).danmaku-item{display:none!important;}',
small: '.chat-item:not(.hover):not(.system-msg) > a, .chat-item .guard-icon{display:none !important;}',
gift: '.chat-item:not(.hover).gift-item,.bilibili-live-player-video-area > .bilibili-live-player-video-gift{display:none !important;}',
enterMsg: '.chat-item.important-prompt-item,.chat-item:not(.hover).welcome-msg,.chat-item.welcome-guard{display: none !important;}',
Expand Down
5 changes: 2 additions & 3 deletions src/js/modules/danmu/UI/danmu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import styled from 'styled-components';
import {Button} from 'Components/common/Button';
import {Crc32Engine} from 'Libs/crc32';
import {List} from 'react-virtualized';
import {getFilename} from 'Utils';
import {parseTime} from 'Utils';
import {getFilename, parseTime, encodeHTMLEntries} from 'Utils';
import {theme} from 'Styles';
import './styles.scss';
import 'react-virtualized/styles.css';
Expand Down Expand Up @@ -373,7 +372,7 @@ export default () => {
let xmlStr = `<?xml version="1.0" encoding="UTF-8"?><i><chatserver></chatserver><chatid>${oid}</chatid><mission></mission><maxlimit></maxlimit><state></state><real_name></real_name><source></source>`;
this.danmuDocumentStr = currentFullList.reduce((xml, line) => {
const {danmu, authorHash, mode, progress, fontsize, color, ctime, idStr, weight} = line;
return xmlStr += `<d p="${(progress || 0) / 1000},${mode},${fontsize},${color},${ctime},${weight},${authorHash},${idStr}">${danmu}</d>`;
return xmlStr += `<d p="${(progress || 0) / 1000},${mode},${fontsize},${color},${ctime},${weight},${authorHash},${idStr}">${encodeHTMLEntries(danmu)}</d>`;
}, xmlStr) + '</i>';
});
});
Expand Down
98 changes: 98 additions & 0 deletions src/js/modules/darkMode/UI/VideoBtn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React from 'react';
import store from 'store';
import styled from 'styled-components';
import {Button} from 'Components/common/Button';
import {VideoPlayDarkMode} from 'Modules/darkMode/UI/DarkMode';

/**
* Author: DrowsyFlesh
* Create: 2019-05-14
* Description:
*/

export default () => {
const VideoDarkModeButton = styled(Button).attrs({
className: `bilibili-helper-video-dark-mode-btn`,
})`
position: absolute;
right: 66px;
top: 14px;
border-radius: 4px;
button {
padding: 0 4px;
min-width: unset;
font-size: 12px;
border: 1px solid #fb7299;
border-radius: 4px;
color: ${({on}) => on ? '#fff' : '#fb7299'};
background-color: ${({on}) => on ? '#fb7299' : '#fff'};
cursor: pointer;
}
`;

return class VideoBtn extends React.Component {
constructor(props) {
super(props);
this.darkStore = store.get('videoDark');
this.darkTwoFactor = store.get('videoDarkTwoFactor');
this.state = {
showDark: this.darkStore,
};
this.isOldPageOrWatchLater = !!document.querySelector('#__bofqi,.view-later-module, #bangumi_detail');
}

componentDidMount() {
chrome.runtime.sendMessage({
command: 'getSetting',
feature: 'darkMode',
}, (settings) => {
this.darkGlobal = settings.on;
if (settings.on && !this.darkTwoFactor) {
const darkFollowSys = settings.options.filter((item) => item.key === 'darkFollowSys')[0];
if (darkFollowSys.on) {
const sysDark = matchMedia("(prefers-color-scheme: dark)");
this.setState({showDark: sysDark.matches});
sysDark.onchange = () => {
this.setState({showDark: sysDark.matches});
};
} else {
this.setState({showDark: true});
}
if (this.darkStore === false) {
let time = store.get('videoDarkTime');
time = time !== undefined ? ++time : 1;
if (time > 3) {
store.remove('videoDark');
store.remove('videoDarkTime');
} else {
store.set('videoDarkTime', time);
}
}
}
});
}

handleOnClick = () => {
const on = !this.state.showDark;
this.setState({showDark: on});
store.set('videoDark', on);
if (!on && this.darkStore === false && this.darkGlobal && !this.darkTwoFactor) {
store.set('videoDarkTwoFactor', true);
}
if (on && !this.darkGlobal && this.darkTwoFactor) {
store.set('videoDarkTwoFactor', false);
}
};

render() {
const on = this.state.showDark;
return (
<React.Fragment>
<VideoDarkModeButton onClick={this.handleOnClick}
on={on && !this.isOldPageOrWatchLater}>深色模式</VideoDarkModeButton>
{on && !this.isOldPageOrWatchLater && <VideoPlayDarkMode/>}
</React.Fragment>
);
}
};
}
19 changes: 10 additions & 9 deletions src/js/modules/darkMode/UI/basicStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const TopBarDarkModeStyle = createGlobalStyle`
}
//Card顶上的小尖尖
.van-popper {
.van-popper-vip, .van-popper-favorite, .van-popper-history, .van-popper-upload, .popover-app-download {
.popper__arrow, .popper__arrow::after {
border-bottom-color: var(--dark-3)!important;
}
Expand Down Expand Up @@ -247,14 +247,15 @@ const UserPopperDarkModeStyle = createGlobalStyle`
}
.nameplate-card {
background: var(--dark-3)!important;
border-color: var(--dark-3)!important;
.nameplate-text {
border-color: var(--dark-1)!important;
.n-name, .n-title {
color: var(--dark-font-0)!important;
}
}
background: var(--dark-3)!important;
border-color: var(--dark-3)!important;
.nameplate-text {
border-color: var(--dark-1)!important;
.n-name, .n-title {
color: var(--dark-font-0)!important;
}
}
}
`;

export {
Expand Down
5 changes: 5 additions & 0 deletions src/js/modules/darkMode/UI/cardMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ const DynamicMain = `
.dynamic-list-item-wrap, .forw-more {
border-color: var(--dark-2)!important;
}
//展开相关动态
.fold-box {
border-color: var(--divider)!important;
}
`;

export {
Expand Down
24 changes: 22 additions & 2 deletions src/js/modules/darkMode/UI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* Description:
*/

import _ from "lodash";
import {UI} from 'Libs/UI';
import React from 'react';
import ReactDOM from 'react-dom';
import {HomeDarkMode, DynamicDarkMode, ReadDarkMode, ReadCVDarkMode, ReadRankDarkMode, MessageDarkMode, SpaceDarkMode, WatchLaterDarkMode, HistoryDarkMode, LivePlayDarkMode, SearchDarkMode} from './DarkMode';
import VideoDarkBtnBuilder from './VideoBtn';

export class DarkModeUI extends UI {
constructor() {
Expand All @@ -20,7 +20,7 @@ export class DarkModeUI extends UI {
load = (containers, settings) => {
if (!settings.on) { return Promise.resolve(); }
return new Promise(resolve => {
const darkFollowSys = _.find(settings.options, {key: 'darkFollowSys'});
const darkFollowSys = settings.options.filter((item) => item.key === 'darkFollowSys')[0];
const t = {darkFollowSys: darkFollowSys.on};
const wrapper = document.createElement('style');
const pageName = this.isPage();
Expand Down Expand Up @@ -62,3 +62,23 @@ export class DarkModeUI extends UI {
});
};
}

export class VideoDarkBtnUI extends UI {
constructor() {
super({
name: 'videoDarkBtn',
dependencies: ['videoAnchor'],
});
}

load = ([container]) => {
return new Promise(resolve => {
const VideoDarkBtn = VideoDarkBtnBuilder();
const wrapper = document.createElement('div');
wrapper.setAttribute('class', 'bilibili-helper-video-dark-mode');
wrapper.setAttribute('style', 'position: static; margin: 0;');
container.append(wrapper);
ReactDOM.render(<VideoDarkBtn/>, wrapper, () => resolve(wrapper));
});
};
}
5 changes: 0 additions & 5 deletions src/js/modules/darkMode/UI/pageDynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ const DynamicDarkModeStyle = createGlobalStyle`
}
}
//展开相关动态
.fold-box {
border-color: var(--dark-1)!important;
}
//常看列表
.card-list .most-viewed-panel .list-content .most-viewed-item .section {
.icon-all, .avatar {
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/darkMode/UI/pageHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const HomeDarkModeStyle = createGlobalStyle`
filter: contrast(0.93) brightness(0.89);
}
a, .storey-title .no-link, .manga-panel .manga-list-box .manga-card .manga-title {
a, .storey-title .no-link, .manga-panel .manga-list-box .manga-card .manga-title, .rank-header .name {
color: var(--dark-font-0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/darkMode/UI/pageLive.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const LivePlayDarkModeStyle = createGlobalStyle`
color: var(--dark-font-2)!important;
}
.link-navbar .main-ctnr .nav-logo, .link-navbar .nav-item, .shortcuts-ctnr, .room-title, .tab-list .item.active, .rank-list-box a, .chat-item.danmaku-item,
.link-navbar .main-ctnr .nav-logo, .link-navbar .nav-item, .shortcuts-ctnr, .room-title, .tab-list .item.active, .rank-list-box a.live-skin-main-a-text, .chat-item.danmaku-item,
.gift-item .label, .gift-info-title, .choice-item, .announcement-cntr .content, .record-title, .live-player-ctnr, .area-list-panel .list-item, .username, .user-row,
.gift-component-effect-rule, .share-addr-name, th.list-head-text {
color: var(--dark-font-0)!important;
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/darkMode/UI/pageSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SpaceDarkModeStyle = createGlobalStyle`
//高优先
.feed-title, .section .user-auth.no-auth .no-auth-title .goto-auth, .user-auth .auth-description, .contribution-sidenav, .breadcrumb .item,
.my-album .tab-list .tab:not(.active) .name, .my-album .title, .fav-sidenav, .nav-title .text,
.my-album .tab-list .tab:not(.active) .name, .my-album .title, .fav-sidenav, .nav-title .text,.i-live .i-live-text,
.fav-main .filter-item, .fav-main .filter-item .filter-type .be-dropdown-item span, .favInfo-box .favInfo-details .fav-name,
.pgc-item-title, .pgc-item-desc, .setting-privacy-item .setting-privacy-name, .channel-title .channel-name, .album-title, .follow-item {
color: var(--dark-font-0)!important;
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/darkMode/UI/pageVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ const VideoPlayDarkModeStyle = createGlobalStyle`
.rec-title {
color: var(--dark-font-3);
}
.rec-list .card-box {
.card-box {
.pic-box {
background: var(--dark-1)!important;
}
Expand Down
17 changes: 16 additions & 1 deletion src/js/modules/darkMode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {Feature} from 'Libs/feature';
import {__} from 'Utils/functions';
export {DarkModeUI} from './UI/index';
export {DarkModeUI, VideoDarkBtnUI} from './UI/index';

export class DarkMode extends Feature {
constructor() {
Expand All @@ -30,3 +30,18 @@ export class DarkMode extends Feature {
});
}
}

export class VideoDarkBtn extends Feature {
constructor() {
super({
name: 'videoDarkBtn',
kind: 'video',
dependencies: ['videoAnchor'],
settings: {
on: true,
hide: true,
hasUI: true,
},
});
}
}
4 changes: 3 additions & 1 deletion src/js/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {ShowDisabledVideo, ShowDisabledVideoUI} from 'Modules/ShowDisabledVideo'
import {LivePictureInPicture, LivePictureInPictureUI} from 'Modules/LivePictureInPicture';
import {AutoTakeVipPrivilege, AutoTakeVipPrivilegeUI} from 'Modules/autoTakeVipPrivilege';
import {LiveReplayDownload, LiveReplayDownloadUI} from 'Modules/liveReplayDownload';
import {DarkMode, DarkModeUI} from "Modules/darkMode";
import {DarkMode, DarkModeUI, VideoDarkBtn, VideoDarkBtnUI} from "Modules/darkMode";
import {PartitionFilter, PartitionFilterUI} from "Modules/partitionFilter";

//let VideoUnblock;
Expand Down Expand Up @@ -60,6 +60,7 @@ export const Features = {
PartitionFilter,
Silver2coin,
DarkMode,
VideoDarkBtn,
QuickSearch,
VideoHideDanmu,
LiveChatMode,
Expand Down Expand Up @@ -97,5 +98,6 @@ export const UIs = {
AutoTakeVipPrivilegeUI,
LiveReplayDownloadUI,
DarkModeUI,
VideoDarkBtnUI,
PartitionFilterUI,
};
2 changes: 1 addition & 1 deletion src/js/modules/language/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Language extends Feature {

launch = () => {
langOption = {
lang: (this.store && this.store.subPage && this.store.subPage.value) || navigator.language,
lang: (this.store && this.store.subPage && this.store.subPage.value) || navigator.language || chrome.i18n.getUILanguage(),
t: Date.now(),
};

Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/liveReplayDownload/UI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class LiveReplayDownloadUI extends UI {
fragmentBtn.setAttribute('download', '');
fragmentBtn.setAttribute('target', '__blank');
fragmentBtn.setAttribute('referrerPolicy', 'unsafe-url');
fragmentBtn.href = fragment.url;
fragmentBtn.href = fragment.url.replace(/^http:\/\//, 'https://');
fragmentBtn.innerText = `${index + 1}`;
dom.appendChild(fragmentBtn);
});
Expand Down
13 changes: 7 additions & 6 deletions src/js/modules/partitionFilter/UI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
*/

import {UI} from 'Libs/UI';
import $ from 'jquery';

export class PartitionFilterUI extends UI {

constructor() {
super({
name: 'PartitionFilter',
Expand Down Expand Up @@ -57,14 +55,18 @@ export class PartitionFilterUI extends UI {
this.filterMain(key);
this.filterListBox(key);
});
document.querySelector('div.proxy-box').style.minHeight = 'unset';
}
resolve();
});
};

getFilterItemInListBox = (key) => this.kindDOMMap[this.kindNameMap[key]];

filterMain = (key) => $('#bili_' + key).hide();
filterMain = (key) => {
const target = document.getElementById('bili_' + key);
if (target) {
target.style.display = 'none';
}
};

filterListBox = (key) => {
const nameList = this.kindNameMap[key];
Expand All @@ -75,5 +77,4 @@ export class PartitionFilterUI extends UI {
}
});
};

}
2 changes: 1 addition & 1 deletion src/js/modules/partitionFilter/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"partitionFilter_subPage_options_movie": {
"message": "电影"
},
"partitionFilter_subPage_options_film": {
"partitionFilter_subPage_options_cinephile": {
"message": "影视"
},
"partitionFilter_subPage_options_read": {
Expand Down
Loading

0 comments on commit 20ab28f

Please sign in to comment.