diff --git a/bilibili-evolved.js b/bilibili-evolved.js
index a9073f0ec..5aef985de 100644
--- a/bilibili-evolved.js
+++ b/bilibili-evolved.js
@@ -7,8 +7,19 @@
// @match *://*.bilibili.com/*
// @match *://*.bilibili.com
// @grant unsafeWindow
+// @resource style https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/style/style.scss
+// @resource touchPlayerStyle https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/style/style-touch-player.scss
+// @resource oldStyle https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/style/style-old.scss
+// @resource darkStyle https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/style/style-dark.scss
// @require https://static.hdslb.com/js/jquery.min.js
// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/utils/common.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/utils/remove-ads.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/utils/watchlater.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/utils/expand-danmaku.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/touch/touch-navbar.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/touch/touch-player.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/style/new-styles.min.js
+// @require https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/style/dark-styles.min.js
// ==/UserScript==
(self$ =>
@@ -82,2588 +93,49 @@
{
return element.data("events")[event][0].handler;
};
-
+
$(document).ready(() =>
{
- // Remove ads
if (settings.removeAds)
{
- waitForQuery()(
- () => $("#slide_ad"),
- it => it.length > 0,
- it => it.css("display", "none")
- );
- waitForQuery()(
- () => $("#home_popularize"),
- it => it.length > 0,
- it => it.css("display", "none")
- );
- waitForQuery()(
- () => $(".gg-floor-module"),
- it => it.length > 0,
- it => it.css("display", "none")
- );
+ removeAds();
}
-
- // Touch nav bar
if (settings.touchNavBar)
{
- waitForQuery()(
- () => $("ul.fr>li.nav-item").not(".profile-info"),
- it => it.length === 6,
- navItems =>
- {
- const navTouch = (_, nav) =>
- {
- const $nav = $(nav);
- $nav.css("cursor", "pointer");
- const a = $nav.find("a.t");
- a.removeAttr("href");
- };
- navItems.each(navTouch);
- }
- );
+ touchNavBar();
}
-
- // Touch video player
- const touchVideoPlayer = () =>
+ if (settings.touchVideoPlayer)
{
- waitForQuery()(
- () => $(".bilibili-player-video-web-fullscreen"),
- it => it.length > 0,
- fullscreenButton =>
- {
- if (!fullscreenButton.hasClass("bilibili-player-video-btn") &&
- $(".bilibili-player-video-btn-fullscreen").data("events"))
- {
- const clickHandler = getEventHandler(
- $(".bilibili-player-video-btn-fullscreen"), "click");
- fullscreenButton
- .detach()
- .insertAfter(".bilibili-player-video-btn-widescreen")
- .addClass("bilibili-player-video-btn")
- .on("click", clickHandler);
- }
- }
- );
- waitForQuery()(
- () => $(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),
- it => it.length > 0,
- icons => icons.unbind("click")
- );
- waitForQuery()(
- () => $(".bilibili-player-video"),
- it => it.length > 0 && $("video").length > 0,
- player =>
- {
- if ($(".touch-video-box").length === 0)
- {
- $(".bilibili-player-video-subtitle").before(`
`);
- const swiper = new Swiper(player.get(0));
- const text = document.getElementsByClassName("touch-video-info")[0];
- const box = document.getElementsByClassName("touch-video-box")[0];
- swiper.action.speedCancel = () =>
- {
- text.innerHTML = `松开手指,取消进退`;
- };
- swiper.action.volumeCancel = () =>
- {
- text.innerHTML = `松开手指,取消调整`;
- };
- swiper.action.onActionStart = () =>
- {
- box.style.display = "flex";
- text.innerHTML = "";
- };
-
- const fixed = (number, precision = 1) =>
- {
- const str = number.toString();
- const index = str.indexOf(".");
- if (index !== -1)
- {
- if (str.length - index > precision + 1)
- {
- return str.substring(0, index + precision + 1);
- }
- else
- {
- return str;
- }
- }
- else
- {
- return str + ".0";
- }
- };
- const secondsToTime = sec =>
- {
- sec = Math.abs(sec);
- const hours = Math.floor(sec / 3600);
- const minutes = Math.floor((sec - hours * 3600) / 60);
- const seconds = sec - hours * 3600 - minutes * 60;
-
- let result = fixed(seconds) + "秒";
- if (minutes > 0)
- {
- result = minutes + "分" + result;
- }
- if (hours > 0)
- {
- result = hours + "小时" + result;
- }
-
- return result;
- };
- const secondsToHms = sec =>
- {
- sec = Math.abs(sec);
- const hours = Math.floor(sec / 3600);
- const minutes = Math.floor((sec - hours * 3600) / 60);
- const seconds = sec - hours * 3600 - minutes * 60;
-
- let result = (seconds < 10 ? "0" : "") + fixed(seconds);
- result = (minutes < 10 ? "0" : "") + minutes + ":" + result;
- result = (hours < 10 ? "0" : "") + hours + ":" + result;
-
- return result;
- };
-
- const video = $("video");
- const videoDuration = video.prop("duration");
- //const videoshot = new VideoShot(videoDuration);
- const speedChange = speed =>
- {
- return sec =>
- {
- const current = video.prop("currentTime");
- let info = `${speed}速进度: ${sec > 0 ? "+" : "-"}`;
- const commonInfoPart = `
`;
- const finalTime = current + sec;
- if (finalTime > videoDuration)
- {
- info += `${secondsToTime(videoDuration - current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(videoDuration)} (100%)`;
- }
- else if (finalTime < 0)
- {
- info += `${secondsToTime(current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(0)} (0%)`;
- }
- else
- {
- info += `${secondsToTime(sec)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(finalTime)} (${fixed(100 * finalTime / videoDuration)}%)`;
- }
- text.innerHTML = info + ` `;
- //$(".videoshot").css(videoshot.getStyle(finalTime));
- };
- };
- swiper.action.lowSpeedBackward = speedChange("低");
- swiper.action.lowSpeedForward = speedChange("低");
- swiper.action.mediumSpeedBackward = speedChange("中");
- swiper.action.mediumSpeedForward = speedChange("中");
- swiper.action.highSpeedBackward = speedChange("高");
- swiper.action.highSpeedForward = speedChange("高");
-
- const volumeChange = speed =>
- {
- return volume =>
- {
- const current = Math.round(video.prop("volume") * 100);
- let info = `${speed}速音量: ${volume > 0 ? "+" : "-"}`;
- const commonInfoPart = `
`;
- const finalVolume = current + volume;
- if (finalVolume > 100)
- {
- info += `${100 - current}${commonInfoPart}${current} → 100`;
- }
- else if (finalVolume < 0)
- {
- info += `${current}${commonInfoPart}${current} → 0`;
- }
- else
- {
- info += `${Math.abs(volume)}${commonInfoPart}${current} → ${finalVolume}`;
- }
- text.innerHTML = info + `
`;
- };
- };
- swiper.action.lowVolumeUp = volumeChange("低");
- swiper.action.lowVolumeDown = volumeChange("低");
- swiper.action.mediumVolumeUp = volumeChange("中");
- swiper.action.mediumVolumeDown = volumeChange("中");
- swiper.action.highVolumeUp = volumeChange("高");
- swiper.action.highVolumeDown = volumeChange("高");
-
- swiper.action.onActionEnd = action =>
- {
- box.style.display = "none";
- text.innerHTML = "";
- if (action)
- {
- if (action.type === "volume")
- {
- let volume = video.prop("volume");
- volume += action.volume / 100;
- if (volume < 0)
- {
- volume = 0;
- }
- else if (volume > 1)
- {
- volume = 1;
- }
- video.prop("volume", volume);
- $(".bilibili-player-video-volume-num").text(Math.round(volume * 100));
- $(".bpui-slider-progress").css("height", volume * 100 + "%");
- $(".bpui-slider-handle").css("bottom", (35 + volume * 230) / 3 + "%");
-
- if (volume === 0)
- {
- $(".icon-24soundoff").show();
- $(".icon-24soundlarge").hide();
- $(".icon-24soundsmall").hide();
- }
- else if (volume >= 0.5)
- {
- $(".icon-24soundoff").hide();
- $(".icon-24soundlarge").show();
- $(".icon-24soundsmall").hide();
- }
- else
- {
- $(".icon-24soundoff").hide();
- $(".icon-24soundlarge").hide();
- $(".icon-24soundsmall").show();
- }
- }
- else if (action.type === "playback")
- {
- let time = video.prop("currentTime");
- time += action.seconds;
- if (time < 0)
- {
- time = 0;
- }
- else if (time > videoDuration)
- {
- time = videoDuration;
- }
- video.prop("currentTime", time);
- }
- }
- };
- }
- }
- );
-
- if ($("#bilibili-touch-video-player").length === 0)
+ touchVideoPlayer();
+ $(document).ajaxComplete(() =>
{
- const videoPlayerStyles = ``;
- $("body").after(videoPlayerStyles);
- }
- // waitForQuery()(
- // () => $(".bilibili-player-video-progress-detail-img"),
- // it => it.length > 0,
- // videoshot =>
- // {
-
- // }
- // );
-
- };
- touchVideoPlayer();
-
- // Watch later redirect
- const watchlaterRedirect = () =>
+ touchVideoPlayer();
+ });
+ }
+ if (settings.watchLaterRedirect)
{
- if (settings.watchLaterRedirect)
+ watchlaterRedirect();
+ $(document).ajaxComplete(() =>
{
- const redirectLinks = items =>
- {
- if (items.attr("href").indexOf("watchlater") !== 0)
- {
- const watchlaterList = items
- .map((_, it) => "https://www.bilibili.com/" + $(it)
- .attr("href")
- .match(/av[\d]+/)[0]);
- items.each((index, it) => $(it).attr("href", watchlaterList[index]).attr("target", "_blank"));
- }
- };
- waitForQuery()(
- () => $(".av-item>a"),
- it => it.length > 0,
- items => redirectLinks(items)
- );
- waitForQuery()(
- () => $("div.watch-later-m>ul>div>li>a"),
- it => it.length > 0,
- items => redirectLinks(items)
- );
- waitForQuery()(
- () => $(".read-more.mr"),
- it => it.length > 0,
- it => it.remove()
- );
- waitForQuery()(
- () => $(".read-more-grp>.read-more"),
- it => it.length > 0,
- it => it.css({
- float: "none",
- width: "auto"
- })
- );
- if (document.URL.indexOf("watchlater") !== -1 && document.URL.match(/av[\d]+/))
- {
- const av = document.URL.match(/av[\d]+/)[0];
- if (av)
- {
- document.URL.replace(`https://www.bilibili.com/${av}`);
- }
- }
- }
- };
- watchlaterRedirect();
-
- // Expand danmaku list
- const expandDanmakuList = () =>
- {
- if (settings.expandDanmakuList)
- {
- waitForQuery()(
- () => $(".bui-collapse-header"),
- it => it.length > 0,
- button =>
- {
- if (parseInt($(".bui-collapse-body").css("height")) === 0 &&
- $(".bui-collapse-arrow-text").text() === "展开")
- {
- button.click();
- }
- }
- );
- }
- };
- expandDanmakuList();
-
- $(document).ajaxComplete(() =>
+ watchlaterRedirect();
+ });
+ }
+ if (settings.expandDanmakuList)
{
expandDanmakuList();
- watchlaterRedirect();
- touchVideoPlayer();
- });
-
- // Styles
+ $(document).ajaxComplete(() =>
+ {
+ expandDanmakuList();
+ });
+ }
if (settings.useNewStyles)
{
- waitForQuery()(
- () => $(".nav-search-keyword"),
- it => it.length > 0,
- textBox => textBox.attr("placeholder", "搜索")
- );
- waitForQuery()(
- () => $(".custom-scrollbar"),
- it => it.length > 0,
- it => it.removeClass("custom-scrollbar")
- );
- // waitForQuery()(
- // () => $("li.home>a"),
- // it => it.length > 0 && it.css("font-size").indexOf("12px") !== -1,
- // it => it.css("font-size", "0px")
- // );
-
- const getForeground = () =>
- {
- const regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(settings.customStyleColor);
- const color = regex ? {
- r: parseInt(regex[1], 16),
- g: parseInt(regex[2], 16),
- b: parseInt(regex[3], 16)
- } : undefined;
- if (color)
- {
- const grey = 1 - (0.299 * color.r + 0.587 * color.g + 0.114 * color.b) / 255;
- if (grey < 0.35)
- {
- return "#000";
- }
- else
- {
- return "#fff";
- }
- }
- else
- {
- return "#fff";
- }
- };
-
- const updateDarkModeColor = () =>
- {
- if (settings.useDarkMode)
- {
- const foreground = getForeground();
- const darkStyles = ``;
- $("#bilibili-new-style-dark").remove();
- $("body").after(darkStyles);
- }
- };
- const updateStyleColor = () =>
- {
- const foreground = getForeground();
- const navbar = document.getElementsByClassName("bili-wrapper")[0];
- let useFlexStyles = false;
- if (navbar instanceof Element)
- {
- useFlexStyles = parseInt(window.getComputedStyle(navbar).height) === 50;
- }
- let styles = "";
- if (useFlexStyles)
- {
- styles = ``;
- }
- else
- {
- styles = ``;
-
-
- if (settings.overrideNavBar)
- {
- waitForQuery()(
- () => $(".search"),
- it => it.length > 0 && $(".nav-con.fr").length > 0,
- textBox =>
- {
- textBox.detach()
- .insertAfter(".nav-con.fr");
- }
- );
- waitForQuery()(
- () => $("input.search-keyword"),
- it => it.length > 0,
- textBox => textBox.attr("placeholder", "搜索")
- );
- const navBarStyles = ``;
- $("body").after(navBarStyles);
-
- if (!settings.showBanner)
- {
- const bannerStyles = ``;
- $("body").after(bannerStyles);
- }
- }
- }
- $("#bilibili-new-style").remove();
- $("body").after(styles);
- };
- const updateColors = () =>
- {
- updateDarkModeColor();
- updateStyleColor();
- };
- updateColors();
-
- // if (settings.useDominantColor && !(settings.overrideNavBar && !settings.showBanner))
- // {
- // waitForQuery()(
- // () => $("#banner_link"),
- // it => it.length > 0 && it.css("background-image") !== "none",
- // image =>
- // {
- // const src = image.css("background-image").match(/url\("(.+)"\)/)[1];
- // RGBaster.colors(src, {
- // success: color =>
- // {
- // settings.customStyleColor = color.dominant;
- // updateColors();
- // }
- // });
- // }
- // );
- // }
+ newStyle();
+ }
+ if (settings.useDarkMode)
+ {
+ darkStyle();
}
-
});
})(window.jQuery.noConflict(true));
diff --git a/style/dark-styles.js b/style/dark-styles.js
new file mode 100644
index 000000000..37545957f
--- /dev/null
+++ b/style/dark-styles.js
@@ -0,0 +1,6 @@
+function darkStyle()
+{
+ const styles = ``;
+ $("#bilibili-new-style-dark").remove();
+ $("body").after(darkStyles);
+}
diff --git a/style/dark-styles.min.js b/style/dark-styles.min.js
new file mode 100644
index 000000000..ede67f176
--- /dev/null
+++ b/style/dark-styles.min.js
@@ -0,0 +1 @@
+function darkStyle(){const styles=``;$("#bilibili-new-style-dark").remove(),$("body").after(darkStyles)}
\ No newline at end of file
diff --git a/style/new-styles.js b/style/new-styles.js
new file mode 100644
index 000000000..26746ffa4
--- /dev/null
+++ b/style/new-styles.js
@@ -0,0 +1,31 @@
+function newStyle()
+{
+ waitForQuery()(
+ () => $(".nav-search-keyword"),
+ it => it.length > 0,
+ textBox => textBox.attr("placeholder", "搜索")
+ );
+ waitForQuery()(
+ () => $(".custom-scrollbar"),
+ it => it.length > 0,
+ it => it.removeClass("custom-scrollbar")
+ );
+ const navbar = document.getElementsByClassName("bili-wrapper")[0];
+ let stardustStyles = false;
+ if (navbar instanceof Element)
+ {
+ stardustStyles = parseInt(window.getComputedStyle(navbar).height) === 50;
+ }
+ let styles = "";
+ if (stardustStyles)
+ {
+ styles = getStyle("style");
+ }
+ else
+ {
+ styles = getStyle("oldStyle");
+ }
+ styles = ``;
+ $("#bilibili-new-style").remove();
+ $("body").after(styles);
+}
diff --git a/style/new-styles.min.js b/style/new-styles.min.js
new file mode 100644
index 000000000..07b8fbe0a
--- /dev/null
+++ b/style/new-styles.min.js
@@ -0,0 +1 @@
+function newStyle(){waitForQuery()(()=>$(".nav-search-keyword"),it=>it.length>0,textBox=>textBox.attr("placeholder","搜索")),waitForQuery()(()=>$(".custom-scrollbar"),it=>it.length>0,it=>it.removeClass("custom-scrollbar"));const navbar=document.getElementsByClassName("bili-wrapper")[0];let stardustStyles=!1;navbar instanceof Element&&(stardustStyles=50===parseInt(window.getComputedStyle(navbar).height));let styles="";styles=``,$("#bilibili-new-style").remove(),$("body").after(styles)}
\ No newline at end of file
diff --git a/style/style-touch-player.scss b/style/style-touch-player.scss
new file mode 100644
index 000000000..5d21bc42e
--- /dev/null
+++ b/style/style-touch-player.scss
@@ -0,0 +1,143 @@
+.touch-video-box-wrapper
+{
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ z-index: 14;
+ pointer-events: none;
+}
+.touch-video-box
+{
+ border-radius: 4px;
+ display: none;
+ align-items: center;
+ justify-content: center;
+ width: 50%;
+ height: 40%;
+ background: #000;
+ background: #000A;
+ backdrop-filter: blur(30px);
+}
+.touch-video-info
+{
+ color: white;
+ font-size: 2rem;
+ text-align: center;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-direction: column;
+ height: 100%;
+ width: 100%;
+}
+.touch-row
+{
+ flex-grow: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+}
+.touch-info
+{
+ display: block;
+ flex-grow: 1;
+ flex-shrink: 0;
+ margin-right: 1em;
+ margin-left: 0.2em;
+ color: $customStyleColor;
+ max-width: 15em;
+}
+.touch-result
+{
+ display: block;
+ flex-grow: 1;
+ flex-shrink: 0;
+ font-size: 1.5rem;
+}
+.touch-speed
+{
+ display: block;
+ flex-grow: 2;
+ flex-shrink: 0;
+ background: #444A;
+ padding: 0.5em;
+ margin-left: 1em;
+ border-radius: 4px;
+ margin-right: 0.2em;
+ max-width: 5em;
+}
+.videoshot
+{
+ display:none;
+
+ background-image: none;
+ flex-grow: 0;
+ flex-shrink: 0;
+ border-radius: 4px;
+ width: 80px;
+ height: 45px;
+ background-size: 1000%;
+ margin-left: 1em;
+}
+div.bilibili-player-video-control
+{
+ height: 38px !important;
+ align-items: center !important;
+}
+.bilibili-player-video-btn
+{
+ flex-grow: 1 !important;
+ height: 38px !important;
+ display: flex !important;
+ align-items: center !important;
+ justify-content: center !important;
+}
+.bilibili-player-video-inputbar,
+.bilibili-player-video-progress
+{
+ flex-grow: 30 !important;
+}
+.bilibili-player-video-quality-menu
+{
+ display: flex !important;
+ align-items: center !important;
+ justify-content: center !important;
+}
+.bilibili-player-iconfont-start,
+.bilibili-player-iconfont-pause,
+.bilibili-player-iconfont-volume,
+.bilibili-player-iconfont-volume-max,
+.bilibili-player-iconfont-volume-min,
+.bilibili-player-iconfont-setting,
+.bilibili-player-iconfont-danmaku,
+.bilibili-player-iconfont-danmaku-off,
+.bilibili-player-iconfont-repeat,
+.bilibili-player-iconfont-widescreen,
+.bilibili-player-iconfont-web-fullscreen,
+.bilibili-player-iconfont-fullscreen,
+.bilibili-player-iconfont-color
+{
+ font-size: 2.5rem !important;
+}
+.bilibili-player-iconfont-next
+{
+ font-size: 2rem !important;
+}
+.bpui-selectmenu-list,
+.bilibili-player-video-danmaku-setting-wrap,
+.bilibili-player-video-btn-setting-panel,
+.bilibili-player.mode-fullscreen .bilibili-player-video-sendbar
+{
+ left: unset !important;
+ bottom: 38px !important;
+}
+.bilibili-player-video-volumebar-wrp
+{
+ left: unset !important;
+}
diff --git a/touch/touch-navbar.js b/touch/touch-navbar.js
index e69de29bb..cb2b3e6f7 100644
--- a/touch/touch-navbar.js
+++ b/touch/touch-navbar.js
@@ -0,0 +1,18 @@
+function touchNavBar()
+{
+ waitForQuery()(
+ () => $("ul.fr>li.nav-item").not(".profile-info"),
+ it => it.length === 6,
+ navItems =>
+ {
+ const navTouch = (_, nav) =>
+ {
+ const $nav = $(nav);
+ $nav.css("cursor", "pointer");
+ const a = $nav.find("a.t");
+ a.removeAttr("href");
+ };
+ navItems.each(navTouch);
+ }
+ );
+}
diff --git a/touch/touch-navbar.min.js b/touch/touch-navbar.min.js
new file mode 100644
index 000000000..d6bcc95bb
--- /dev/null
+++ b/touch/touch-navbar.min.js
@@ -0,0 +1 @@
+function touchNavBar(){waitForQuery()(()=>$("ul.fr>li.nav-item").not(".profile-info"),it=>6===it.length,navItems=>{const navTouch=(_,nav)=>{const $nav=$(nav);$nav.css("cursor","pointer");const a=$nav.find("a.t");a.removeAttr("href")};navItems.each(navTouch)})}
\ No newline at end of file
diff --git a/touch/touch-player.js b/touch/touch-player.js
index eed996454..b81287f9e 100644
--- a/touch/touch-player.js
+++ b/touch/touch-player.js
@@ -244,3 +244,243 @@ class SwipeAction
}
}
}
+const touchVideoPlayer = () =>
+{
+ waitForQuery()(
+ () => $(".bilibili-player-video-web-fullscreen"),
+ it => it.length > 0,
+ fullscreenButton =>
+ {
+ if (!fullscreenButton.hasClass("bilibili-player-video-btn") &&
+ $(".bilibili-player-video-btn-fullscreen").data("events"))
+ {
+ const clickHandler = getEventHandler(
+ $(".bilibili-player-video-btn-fullscreen"), "click");
+ fullscreenButton
+ .detach()
+ .insertAfter(".bilibili-player-video-btn-widescreen")
+ .addClass("bilibili-player-video-btn")
+ .on("click", clickHandler);
+ }
+ }
+ );
+ waitForQuery()(
+ () => $(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),
+ it => it.length > 0,
+ icons => icons.unbind("click")
+ );
+ waitForQuery()(
+ () => $(".bilibili-player-video"),
+ it => it.length > 0 && $("video").length > 0,
+ player =>
+ {
+ if ($(".touch-video-box").length === 0)
+ {
+ $(".bilibili-player-video-subtitle").before(``);
+ const swiper = new Swiper(player.get(0));
+ const text = document.getElementsByClassName("touch-video-info")[0];
+ const box = document.getElementsByClassName("touch-video-box")[0];
+ swiper.action.speedCancel = () =>
+ {
+ text.innerHTML = `松开手指,取消进退`;
+ };
+ swiper.action.volumeCancel = () =>
+ {
+ text.innerHTML = `松开手指,取消调整`;
+ };
+ swiper.action.onActionStart = () =>
+ {
+ box.style.display = "flex";
+ text.innerHTML = "";
+ };
+
+ const fixed = (number, precision = 1) =>
+ {
+ const str = number.toString();
+ const index = str.indexOf(".");
+ if (index !== -1)
+ {
+ if (str.length - index > precision + 1)
+ {
+ return str.substring(0, index + precision + 1);
+ }
+ else
+ {
+ return str;
+ }
+ }
+ else
+ {
+ return str + ".0";
+ }
+ };
+ const secondsToTime = sec =>
+ {
+ sec = Math.abs(sec);
+ const hours = Math.floor(sec / 3600);
+ const minutes = Math.floor((sec - hours * 3600) / 60);
+ const seconds = sec - hours * 3600 - minutes * 60;
+
+ let result = fixed(seconds) + "秒";
+ if (minutes > 0)
+ {
+ result = minutes + "分" + result;
+ }
+ if (hours > 0)
+ {
+ result = hours + "小时" + result;
+ }
+
+ return result;
+ };
+ const secondsToHms = sec =>
+ {
+ sec = Math.abs(sec);
+ const hours = Math.floor(sec / 3600);
+ const minutes = Math.floor((sec - hours * 3600) / 60);
+ const seconds = sec - hours * 3600 - minutes * 60;
+
+ let result = (seconds < 10 ? "0" : "") + fixed(seconds);
+ result = (minutes < 10 ? "0" : "") + minutes + ":" + result;
+ result = (hours < 10 ? "0" : "") + hours + ":" + result;
+
+ return result;
+ };
+
+ const video = $("video");
+ const videoDuration = video.prop("duration");
+ //const videoshot = new VideoShot(videoDuration);
+ const speedChange = speed =>
+ {
+ return sec =>
+ {
+ const current = video.prop("currentTime");
+ let info = `${speed}速进度: ${sec > 0 ? "+" : "-"}`;
+ const commonInfoPart = `
`;
+ const finalTime = current + sec;
+ if (finalTime > videoDuration)
+ {
+ info += `${secondsToTime(videoDuration - current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(videoDuration)} (100%)`;
+ }
+ else if (finalTime < 0)
+ {
+ info += `${secondsToTime(current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(0)} (0%)`;
+ }
+ else
+ {
+ info += `${secondsToTime(sec)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(finalTime)} (${fixed(100 * finalTime / videoDuration)}%)`;
+ }
+ text.innerHTML = info + ` `;
+ //$(".videoshot").css(videoshot.getStyle(finalTime));
+ };
+ };
+ swiper.action.lowSpeedBackward = speedChange("低");
+ swiper.action.lowSpeedForward = speedChange("低");
+ swiper.action.mediumSpeedBackward = speedChange("中");
+ swiper.action.mediumSpeedForward = speedChange("中");
+ swiper.action.highSpeedBackward = speedChange("高");
+ swiper.action.highSpeedForward = speedChange("高");
+
+ const volumeChange = speed =>
+ {
+ return volume =>
+ {
+ const current = Math.round(video.prop("volume") * 100);
+ let info = `${speed}速音量: ${volume > 0 ? "+" : "-"}`;
+ const commonInfoPart = `
`;
+ const finalVolume = current + volume;
+ if (finalVolume > 100)
+ {
+ info += `${100 - current}${commonInfoPart}${current} → 100`;
+ }
+ else if (finalVolume < 0)
+ {
+ info += `${current}${commonInfoPart}${current} → 0`;
+ }
+ else
+ {
+ info += `${Math.abs(volume)}${commonInfoPart}${current} → ${finalVolume}`;
+ }
+ text.innerHTML = info + `
`;
+ };
+ };
+ swiper.action.lowVolumeUp = volumeChange("低");
+ swiper.action.lowVolumeDown = volumeChange("低");
+ swiper.action.mediumVolumeUp = volumeChange("中");
+ swiper.action.mediumVolumeDown = volumeChange("中");
+ swiper.action.highVolumeUp = volumeChange("高");
+ swiper.action.highVolumeDown = volumeChange("高");
+
+ swiper.action.onActionEnd = action =>
+ {
+ box.style.display = "none";
+ text.innerHTML = "";
+ if (action)
+ {
+ if (action.type === "volume")
+ {
+ let volume = video.prop("volume");
+ volume += action.volume / 100;
+ if (volume < 0)
+ {
+ volume = 0;
+ }
+ else if (volume > 1)
+ {
+ volume = 1;
+ }
+ video.prop("volume", volume);
+ $(".bilibili-player-video-volume-num").text(Math.round(volume * 100));
+ $(".bpui-slider-progress").css("height", volume * 100 + "%");
+ $(".bpui-slider-handle").css("bottom", (35 + volume * 230) / 3 + "%");
+
+ if (volume === 0)
+ {
+ $(".icon-24soundoff").show();
+ $(".icon-24soundlarge").hide();
+ $(".icon-24soundsmall").hide();
+ }
+ else if (volume >= 0.5)
+ {
+ $(".icon-24soundoff").hide();
+ $(".icon-24soundlarge").show();
+ $(".icon-24soundsmall").hide();
+ }
+ else
+ {
+ $(".icon-24soundoff").hide();
+ $(".icon-24soundlarge").hide();
+ $(".icon-24soundsmall").show();
+ }
+ }
+ else if (action.type === "playback")
+ {
+ let time = video.prop("currentTime");
+ time += action.seconds;
+ if (time < 0)
+ {
+ time = 0;
+ }
+ else if (time > videoDuration)
+ {
+ time = videoDuration;
+ }
+ video.prop("currentTime", time);
+ }
+ }
+ };
+ }
+ }
+ );
+
+ if ($("#bilibili-touch-video-player").length === 0)
+ {
+ const style = getStyle("touchPlayerStyle");
+ const videoPlayerStyles = ``;
+ $("body").after(videoPlayerStyles);
+ }
+};
diff --git a/touch/touch-player.min.js b/touch/touch-player.min.js
index a1173b97b..98ab2aa7e 100644
--- a/touch/touch-player.min.js
+++ b/touch/touch-player.min.js
@@ -1 +1 @@
-const getPosition=element=>{let x=0,y=0;for(;element&&!isNaN(element.offsetLeft)&&!isNaN(element.offsetTop);)x+=element.offsetLeft-element.scrollLeft,y+=element.offsetTop-element.scrollTop,element=element.offsetParent;return{x:x,y:y}};class Swiper{constructor(element){this.action=new SwipeAction(element),this.onTouchStart=void 0,this.onTouchEnd=void 0,this._direction=null,element.addEventListener("touchstart",e=>{this._xDown=e.touches[0].clientX,this._yDown=e.touches[0].clientY,this.onTouchStart&&this.onTouchStart(e)}),element.addEventListener("touchmove",e=>{if(!this._xDown||!this._yDown)return;const xUp=e.touches[0].clientX,yUp=e.touches[0].clientY,elementPosition=getPosition(element),position={x:(e.touches[0].pageX-elementPosition.x)/element.clientWidth,y:(e.touches[0].pageY-elementPosition.y)/element.clientHeight,width:element.clientWidth,height:element.clientHeight},xDiff=this._xDown-xUp,yDiff=this._yDown-yUp;if(this._direction)"vertical"===this._direction?this.action.startAction(this._direction,yDiff,position):"horizontal"===this._direction&&this.action.startAction(this._direction,-xDiff,position),e.preventDefault();else{let direction="";direction=Math.abs(xDiff)>Math.abs(yDiff)?"horizontal":"vertical",this._direction=direction,e.preventDefault()}}),element.addEventListener("touchend",e=>{this._xDown=null,this._yDown=null,this._direction=null,this.onTouchEnd&&this.onTouchEnd(e)})}}class SwipeAction{constructor(element){this.lowSpeedForward=void 0,this.lowSpeedBackward=void 0,this.mediumSpeedForward=void 0,this.mediumSpeedBackward=void 0,this.highSpeedForward=void 0,this.highSpeedBackward=void 0,this.lowVolumeUp=void 0,this.lowVolumeDown=void 0,this.mediumVolumeUp=void 0,this.mediumVolumeDown=void 0,this.highVolumeUp=void 0,this.highVolumeDown=void 0,this.speedCancel=void 0,this.volumeCancel=void 0,this.minSwipeDistance=20,this.onActionStart=void 0,this.onActionEnd=void 0,this._element=element,this._touchStart=!1,this._startPosition=null,this._lastAction=null,element.addEventListener("touchstart",()=>{this._touchStart=!0}),element.addEventListener("touchend",()=>{this._startPosition=null,this.onActionEnd&&this.onActionEnd(this._lastAction),this._lastAction=null})}startAction(direction,distance,position){if(this._touchStart&&(this.onActionStart&&this.onActionStart(),this._startPosition=position,this._touchStart=!1),"vertical"===direction)if(Math.abs(distance)=1/3&&this._startPosition.x<=2/3?(volumeFactor=1,upHandler=this.mediumVolumeUp,downHandler=this.mediumVolumeDown):(volumeFactor=2,upHandler=this.highVolumeUp,downHandler=this.highVolumeDown),distance>0){const volumeChange=Math.round(100*volumeFactor*(distance-this.minSwipeDistance)/(1.5*position.height));upHandler&&upHandler(volumeChange),this._lastAction={type:"volume",volume:volumeChange}}else{const volumeChange=Math.round(100*volumeFactor*(distance+this.minSwipeDistance)/(1.5*position.height));downHandler&&downHandler(volumeChange),this._lastAction={type:"volume",volume:volumeChange}}}else if("horizontal"===direction)if(position.y<1/3&&(position.x<.1||position.x>.9)||Math.abs(distance)=1/3&&this._startPosition.y<=2/3?(speedFactor=.2,forwardHandler=this.mediumSpeedForward,backwardHandler=this.mediumSpeedBackward):(speedFactor=1,forwardHandler=this.highSpeedForward,backwardHandler=this.highSpeedBackward),distance>0){const seconds=(distance-this.minSwipeDistance)*speedFactor;forwardHandler&&forwardHandler(seconds),this._lastAction={type:"playback",seconds:seconds}}else{const seconds=(distance+this.minSwipeDistance)*speedFactor;backwardHandler&&backwardHandler(seconds),this._lastAction={type:"playback",seconds:seconds}}}}}
\ No newline at end of file
+const getPosition=element=>{let x=0,y=0;for(;element&&!isNaN(element.offsetLeft)&&!isNaN(element.offsetTop);)x+=element.offsetLeft-element.scrollLeft,y+=element.offsetTop-element.scrollTop,element=element.offsetParent;return{x:x,y:y}};class Swiper{constructor(element){this.action=new SwipeAction(element),this.onTouchStart=void 0,this.onTouchEnd=void 0,this._direction=null,element.addEventListener("touchstart",e=>{this._xDown=e.touches[0].clientX,this._yDown=e.touches[0].clientY,this.onTouchStart&&this.onTouchStart(e)}),element.addEventListener("touchmove",e=>{if(!this._xDown||!this._yDown)return;const xUp=e.touches[0].clientX,yUp=e.touches[0].clientY,elementPosition=getPosition(element),position={x:(e.touches[0].pageX-elementPosition.x)/element.clientWidth,y:(e.touches[0].pageY-elementPosition.y)/element.clientHeight,width:element.clientWidth,height:element.clientHeight},xDiff=this._xDown-xUp,yDiff=this._yDown-yUp;if(this._direction)"vertical"===this._direction?this.action.startAction(this._direction,yDiff,position):"horizontal"===this._direction&&this.action.startAction(this._direction,-xDiff,position),e.preventDefault();else{let direction="";direction=Math.abs(xDiff)>Math.abs(yDiff)?"horizontal":"vertical",this._direction=direction,e.preventDefault()}}),element.addEventListener("touchend",e=>{this._xDown=null,this._yDown=null,this._direction=null,this.onTouchEnd&&this.onTouchEnd(e)})}}class SwipeAction{constructor(element){this.lowSpeedForward=void 0,this.lowSpeedBackward=void 0,this.mediumSpeedForward=void 0,this.mediumSpeedBackward=void 0,this.highSpeedForward=void 0,this.highSpeedBackward=void 0,this.lowVolumeUp=void 0,this.lowVolumeDown=void 0,this.mediumVolumeUp=void 0,this.mediumVolumeDown=void 0,this.highVolumeUp=void 0,this.highVolumeDown=void 0,this.speedCancel=void 0,this.volumeCancel=void 0,this.minSwipeDistance=20,this.onActionStart=void 0,this.onActionEnd=void 0,this._element=element,this._touchStart=!1,this._startPosition=null,this._lastAction=null,element.addEventListener("touchstart",()=>{this._touchStart=!0}),element.addEventListener("touchend",()=>{this._startPosition=null,this.onActionEnd&&this.onActionEnd(this._lastAction),this._lastAction=null})}startAction(direction,distance,position){if(this._touchStart&&(this.onActionStart&&this.onActionStart(),this._startPosition=position,this._touchStart=!1),"vertical"===direction)if(Math.abs(distance)=1/3&&this._startPosition.x<=2/3?(volumeFactor=1,upHandler=this.mediumVolumeUp,downHandler=this.mediumVolumeDown):(volumeFactor=2,upHandler=this.highVolumeUp,downHandler=this.highVolumeDown),distance>0){const volumeChange=Math.round(100*volumeFactor*(distance-this.minSwipeDistance)/(1.5*position.height));upHandler&&upHandler(volumeChange),this._lastAction={type:"volume",volume:volumeChange}}else{const volumeChange=Math.round(100*volumeFactor*(distance+this.minSwipeDistance)/(1.5*position.height));downHandler&&downHandler(volumeChange),this._lastAction={type:"volume",volume:volumeChange}}}else if("horizontal"===direction)if(position.y<1/3&&(position.x<.1||position.x>.9)||Math.abs(distance)=1/3&&this._startPosition.y<=2/3?(speedFactor=.2,forwardHandler=this.mediumSpeedForward,backwardHandler=this.mediumSpeedBackward):(speedFactor=1,forwardHandler=this.highSpeedForward,backwardHandler=this.highSpeedBackward),distance>0){const seconds=(distance-this.minSwipeDistance)*speedFactor;forwardHandler&&forwardHandler(seconds),this._lastAction={type:"playback",seconds:seconds}}else{const seconds=(distance+this.minSwipeDistance)*speedFactor;backwardHandler&&backwardHandler(seconds),this._lastAction={type:"playback",seconds:seconds}}}}}const touchVideoPlayer=()=>{if(waitForQuery()(()=>$(".bilibili-player-video-web-fullscreen"),it=>it.length>0,fullscreenButton=>{if(!fullscreenButton.hasClass("bilibili-player-video-btn")&&$(".bilibili-player-video-btn-fullscreen").data("events")){const clickHandler=getEventHandler($(".bilibili-player-video-btn-fullscreen"),"click");fullscreenButton.detach().insertAfter(".bilibili-player-video-btn-widescreen").addClass("bilibili-player-video-btn").on("click",clickHandler)}}),waitForQuery()(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),it=>it.length>0,icons=>icons.unbind("click")),waitForQuery()(()=>$(".bilibili-player-video"),it=>it.length>0&&$("video").length>0,player=>{if(0===$(".touch-video-box").length){$(".bilibili-player-video-subtitle").before("");const swiper=new Swiper(player.get(0)),text=document.getElementsByClassName("touch-video-info")[0],box=document.getElementsByClassName("touch-video-box")[0];swiper.action.speedCancel=(()=>{text.innerHTML="松开手指,取消进退"}),swiper.action.volumeCancel=(()=>{text.innerHTML="松开手指,取消调整"}),swiper.action.onActionStart=(()=>{box.style.display="flex",text.innerHTML=""});const fixed=(number,precision=1)=>{const str=number.toString(),index=str.indexOf(".");return-1!==index?str.length-index>precision+1?str.substring(0,index+precision+1):str:str+".0"},secondsToTime=sec=>{sec=Math.abs(sec);const hours=Math.floor(sec/3600),minutes=Math.floor((sec-3600*hours)/60),seconds=sec-3600*hours-60*minutes;let result=fixed(seconds)+"秒";return minutes>0&&(result=minutes+"分"+result),hours>0&&(result=hours+"小时"+result),result},secondsToHms=sec=>{sec=Math.abs(sec);const hours=Math.floor(sec/3600),minutes=Math.floor((sec-3600*hours)/60),seconds=sec-3600*hours-60*minutes;let result=(seconds<10?"0":"")+fixed(seconds);return result=(hours<10?"0":"")+hours+":"+(result=(minutes<10?"0":"")+minutes+":"+result)},video=$("video"),videoDuration=video.prop("duration"),speedChange=speed=>sec=>{const current=video.prop("currentTime");let info=`${speed}速进度: ${sec>0?"+":"-"}`;const commonInfoPart="
",finalTime=current+sec;info+=finalTime>videoDuration?`${secondsToTime(videoDuration-current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(videoDuration)} (100%)`:finalTime<0?`${secondsToTime(current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(0)} (0%)`:`${secondsToTime(sec)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(finalTime)} (${fixed(100*finalTime/videoDuration)}%)`,text.innerHTML=info+" "};swiper.action.lowSpeedBackward=speedChange("低"),swiper.action.lowSpeedForward=speedChange("低"),swiper.action.mediumSpeedBackward=speedChange("中"),swiper.action.mediumSpeedForward=speedChange("中"),swiper.action.highSpeedBackward=speedChange("高"),swiper.action.highSpeedForward=speedChange("高");const volumeChange=speed=>volume=>{const current=Math.round(100*video.prop("volume"));let info=`${speed}速音量: ${volume>0?"+":"-"}`;const commonInfoPart="
",finalVolume=current+volume;info+=finalVolume>100?`${100-current}${commonInfoPart}${current} → 100`:finalVolume<0?`${current}${commonInfoPart}${current} → 0`:`${Math.abs(volume)}${commonInfoPart}${current} → ${finalVolume}`,text.innerHTML=info+"
"};swiper.action.lowVolumeUp=volumeChange("低"),swiper.action.lowVolumeDown=volumeChange("低"),swiper.action.mediumVolumeUp=volumeChange("中"),swiper.action.mediumVolumeDown=volumeChange("中"),swiper.action.highVolumeUp=volumeChange("高"),swiper.action.highVolumeDown=volumeChange("高"),swiper.action.onActionEnd=(action=>{if(box.style.display="none",text.innerHTML="",action)if("volume"===action.type){let volume=video.prop("volume");(volume+=action.volume/100)<0?volume=0:volume>1&&(volume=1),video.prop("volume",volume),$(".bilibili-player-video-volume-num").text(Math.round(100*volume)),$(".bpui-slider-progress").css("height",100*volume+"%"),$(".bpui-slider-handle").css("bottom",(35+230*volume)/3+"%"),0===volume?($(".icon-24soundoff").show(),$(".icon-24soundlarge").hide(),$(".icon-24soundsmall").hide()):volume>=.5?($(".icon-24soundoff").hide(),$(".icon-24soundlarge").show(),$(".icon-24soundsmall").hide()):($(".icon-24soundoff").hide(),$(".icon-24soundlarge").hide(),$(".icon-24soundsmall").show())}else if("playback"===action.type){let time=video.prop("currentTime");(time+=action.seconds)<0?time=0:time>videoDuration&&(time=videoDuration),video.prop("currentTime",time)}})}}),0===$("#bilibili-touch-video-player").length){const style=getStyle("touchPlayerStyle"),videoPlayerStyles=``;$("body").after(videoPlayerStyles)}};
\ No newline at end of file
diff --git a/utils/common.js b/utils/common.js
index ef8e1992c..dcd9e6a81 100644
--- a/utils/common.js
+++ b/utils/common.js
@@ -1,4 +1,4 @@
-const waitForQuery = settings =>
+function waitForQuery()
{
const MaxRetry = settings.maxQueryRetry;
let retry = 0;
@@ -26,4 +26,44 @@ const waitForQuery = settings =>
}
};
return tryQuery;
-};
+}
+function getStyle(name)
+{
+ const style = GM_getResourceText(name);
+ function replaceCustomColor(style)
+ {
+ const foreground = (() =>
+ {
+ const regex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(settings.customStyleColor);
+ const color = regex ? {
+ r: parseInt(regex[1], 16),
+ g: parseInt(regex[2], 16),
+ b: parseInt(regex[3], 16)
+ } : undefined;
+ if (color)
+ {
+ const grey = 1 - (0.299 * color.r + 0.587 * color.g + 0.114 * color.b) / 255;
+ if (grey < 0.35)
+ {
+ return "#000";
+ }
+ else
+ {
+ return "#fff";
+ }
+ }
+ else
+ {
+ return "#fff";
+ }
+ })();
+ settings.brightness = `${foreground === "#000" ? "100" : "0"}%`;
+ settings.filterBrightness = foreground === "#000" ? "0" : "100";
+ for (name of settings)
+ {
+ style = style.replace(`$${name}`, settings[name]);
+ }
+ return style;
+ }
+ return replaceCustomColor(style, foreground);
+}
diff --git a/utils/common.min.js b/utils/common.min.js
index 0b91171a8..aa47ea6a7 100644
--- a/utils/common.min.js
+++ b/utils/common.min.js
@@ -1 +1 @@
-const waitForQuery=settings=>{const MaxRetry=settings.maxQueryRetry;let retry=0;const tryQuery=(query,condition,action,failed)=>{if(retry>=MaxRetry){if(failed){failed()}}else{const result=query();if(condition(result)){action(result)}else{retry++;setTimeout(()=>tryQuery(query,condition,action,failed),settings.queryInterval)}}};return tryQuery};
\ No newline at end of file
+function waitForQuery(){const MaxRetry=settings.maxQueryRetry;let retry=0;const tryQuery=(query,condition,action,failed)=>{if(retry>=MaxRetry)failed&&failed();else{const result=query();condition(result)?action(result):(retry++,setTimeout(()=>tryQuery(query,condition,action,failed),settings.queryInterval))}};return tryQuery}function getStyle(name){const style=GM_getResourceText(name);function replaceCustomColor(style){const foreground=(()=>{const regex=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(settings.customStyleColor),color=regex?{r:parseInt(regex[1],16),g:parseInt(regex[2],16),b:parseInt(regex[3],16)}:void 0;if(color){const grey=1-(.299*color.r+.587*color.g+.114*color.b)/255;return grey<.35?"#000":"#fff"}return"#fff"})();for(name of(settings.brightness=`${"#000"===foreground?"100":"0"}%`,settings.filterBrightness="#000"===foreground?"0":"100",settings))style=style.replace(`$${name}`,settings[name]);return style}return replaceCustomColor(style,foreground)}
\ No newline at end of file
diff --git a/utils/expand-danmaku.js b/utils/expand-danmaku.js
index e69de29bb..cc7e43c2f 100644
--- a/utils/expand-danmaku.js
+++ b/utils/expand-danmaku.js
@@ -0,0 +1,15 @@
+function expandDanmakuList()
+{
+ waitForQuery()(
+ () => $(".bui-collapse-header"),
+ it => it.length > 0,
+ button =>
+ {
+ if (parseInt($(".bui-collapse-body").css("height")) === 0 &&
+ $(".bui-collapse-arrow-text").text() === "展开")
+ {
+ button.click();
+ }
+ }
+ );
+}
diff --git a/utils/expand-danmaku.min.js b/utils/expand-danmaku.min.js
new file mode 100644
index 000000000..0672f5eb1
--- /dev/null
+++ b/utils/expand-danmaku.min.js
@@ -0,0 +1 @@
+function expandDanmakuList(){waitForQuery()(()=>$(".bui-collapse-header"),it=>it.length>0,button=>{0===parseInt($(".bui-collapse-body").css("height"))&&"展开"===$(".bui-collapse-arrow-text").text()&&button.click()})}
\ No newline at end of file
diff --git a/utils/remove-ads.js b/utils/remove-ads.js
index e69de29bb..8b81ab299 100644
--- a/utils/remove-ads.js
+++ b/utils/remove-ads.js
@@ -0,0 +1,18 @@
+function removeAds()
+{
+ waitForQuery()(
+ () => $("#slide_ad"),
+ it => it.length > 0,
+ it => it.css("display", "none")
+ );
+ waitForQuery()(
+ () => $("#home_popularize"),
+ it => it.length > 0,
+ it => it.css("display", "none")
+ );
+ waitForQuery()(
+ () => $(".gg-floor-module"),
+ it => it.length > 0,
+ it => it.css("display", "none")
+ );
+};
diff --git a/utils/remove-ads.min.js b/utils/remove-ads.min.js
new file mode 100644
index 000000000..e093e7424
--- /dev/null
+++ b/utils/remove-ads.min.js
@@ -0,0 +1 @@
+function removeAds(){waitForQuery()(()=>$("#slide_ad"),it=>it.length>0,it=>it.css("display","none")),waitForQuery()(()=>$("#home_popularize"),it=>it.length>0,it=>it.css("display","none")),waitForQuery()(()=>$(".gg-floor-module"),it=>it.length>0,it=>it.css("display","none"))}
\ No newline at end of file
diff --git a/utils/watchlater.js b/utils/watchlater.js
index e69de29bb..4cff887ef 100644
--- a/utils/watchlater.js
+++ b/utils/watchlater.js
@@ -0,0 +1,45 @@
+function watchlaterRedirect()
+{
+ const redirectLinks = items =>
+ {
+ if (items.attr("href").indexOf("watchlater") !== 0)
+ {
+ const watchlaterList = items
+ .map((_, it) => "https://www.bilibili.com/" + $(it)
+ .attr("href")
+ .match(/av[\d]+/)[0]);
+ items.each((index, it) => $(it).attr("href", watchlaterList[index]).attr("target", "_blank"));
+ }
+ };
+ waitForQuery()(
+ () => $(".av-item>a"),
+ it => it.length > 0,
+ items => redirectLinks(items)
+ );
+ waitForQuery()(
+ () => $("div.watch-later-m>ul>div>li>a"),
+ it => it.length > 0,
+ items => redirectLinks(items)
+ );
+ waitForQuery()(
+ () => $(".read-more.mr"),
+ it => it.length > 0,
+ it => it.remove()
+ );
+ waitForQuery()(
+ () => $(".read-more-grp>.read-more"),
+ it => it.length > 0,
+ it => it.css({
+ float: "none",
+ width: "auto"
+ })
+ );
+ if (document.URL.indexOf("watchlater") !== -1 && document.URL.match(/av[\d]+/))
+ {
+ const av = document.URL.match(/av[\d]+/)[0];
+ if (av)
+ {
+ document.URL.replace(`https://www.bilibili.com/${av}`);
+ }
+ }
+}
diff --git a/utils/watchlater.min.js b/utils/watchlater.min.js
new file mode 100644
index 000000000..4917fbaf3
--- /dev/null
+++ b/utils/watchlater.min.js
@@ -0,0 +1 @@
+function watchlaterRedirect(){const redirectLinks=items=>{if(0!==items.attr("href").indexOf("watchlater")){const watchlaterList=items.map((_,it)=>"https://www.bilibili.com/"+$(it).attr("href").match(/av[\d]+/)[0]);items.each((index,it)=>$(it).attr("href",watchlaterList[index]).attr("target","_blank"))}};if(waitForQuery()(()=>$(".av-item>a"),it=>it.length>0,items=>redirectLinks(items)),waitForQuery()(()=>$("div.watch-later-m>ul>div>li>a"),it=>it.length>0,items=>redirectLinks(items)),waitForQuery()(()=>$(".read-more.mr"),it=>it.length>0,it=>it.remove()),waitForQuery()(()=>$(".read-more-grp>.read-more"),it=>it.length>0,it=>it.css({float:"none",width:"auto"})),-1!==document.URL.indexOf("watchlater")&&document.URL.match(/av[\d]+/)){const av=document.URL.match(/av[\d]+/)[0];av&&document.URL.replace(`https://www.bilibili.com/${av}`)}}
\ No newline at end of file