mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
92 lines
2.5 KiB
JavaScript
92 lines
2.5 KiB
JavaScript
const getRedirectLink = text =>
|
|
{
|
|
const match = text.match(/(av[\d]+)\/p([\d]+)/);
|
|
if (match)
|
|
{
|
|
return `https://www.bilibili.com/video/${match[1]}/?p=${match[2]}`;
|
|
}
|
|
else
|
|
{
|
|
return "javascript:;";
|
|
}
|
|
};
|
|
const redirectLinks = items =>
|
|
{
|
|
const watchlaterList = items
|
|
.map(it =>
|
|
{
|
|
const href = it.getAttribute("href");
|
|
if (!href)
|
|
{
|
|
return "javascript:;";
|
|
}
|
|
if (href.match(/.*watchlater.*|javascript:;/g))
|
|
{
|
|
return getRedirectLink(href);
|
|
}
|
|
if (href.indexOf("video/av") !== -1)
|
|
{
|
|
return href;
|
|
}
|
|
});
|
|
items.forEach((it, index) => $(it)
|
|
.attr("href", watchlaterList[index])
|
|
.attr("target", "_blank"));
|
|
};
|
|
const redirectSelectors = (...selectors) =>
|
|
{
|
|
for (const selector of selectors)
|
|
{
|
|
SpinQuery.select(
|
|
() => document.querySelectorAll(selector),
|
|
it => redirectLinks([...it]),
|
|
);
|
|
}
|
|
};
|
|
SpinQuery.any(
|
|
() => $(".watch-later-list"),
|
|
() =>
|
|
{
|
|
(Observer.childListSubtree || Observer.subtree)("#viewlater-app", () =>
|
|
{
|
|
SpinQuery.condition(
|
|
() => document.URL.match(/(av[\d]+)\/p([\d]+)/),
|
|
it => it && document.URL.indexOf("watchlater") !== -1,
|
|
() =>
|
|
{
|
|
const url = getRedirectLink(document.URL);
|
|
if (url !== null)
|
|
{
|
|
window.location.replace(url);
|
|
}
|
|
}
|
|
);
|
|
SpinQuery.any(
|
|
() => $("#viewlater-app .s-btn[href='#/']"),
|
|
it => it.remove(),
|
|
);
|
|
redirectSelectors(".av-pic", ".av-about>a");
|
|
});
|
|
}
|
|
);
|
|
SpinQuery.any(
|
|
() => $("li.nav-item[report-id*=watchlater]"),
|
|
() =>
|
|
{
|
|
(Observer.childListSubtree || Observer.subtree)("li.nav-item[report-id*=watchlater]", () =>
|
|
{
|
|
redirectSelectors(".av-item>a", ".av-about>a", "div.watch-later-m>ul>div>li>a");
|
|
SpinQuery.any(
|
|
() => $(".read-more.mr"),
|
|
it => it.remove()
|
|
);
|
|
SpinQuery.any(
|
|
() => $(".read-more-grp>.read-more"),
|
|
it => it.css({
|
|
float: "none",
|
|
width: "auto"
|
|
})
|
|
);
|
|
});
|
|
}
|
|
); |