您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
使用方法:【edge打开bilibili->右上角->"..."->应用->将此站点安装为应用】优化B站/哔哩哔哩/知乎作为网站应用安装后会跳转浏览器
// ==UserScript== // @name Bilibili网页应用增强(强制所有操作在应用中打开,不跳转edge浏览器) // @description 使用方法:【edge打开bilibili->右上角->"..."->应用->将此站点安装为应用】优化B站/哔哩哔哩/知乎作为网站应用安装后会跳转浏览器 // @version 1 // @author Phoeky // @match https://*.bilibili.com/* // @match https://*.zhihu.com/* // @namespace https://greasyfork.org/users/1247761 // ==/UserScript== (function() { 'use strict'; // Function to change link's target to "_self" const changeLinkTarget = (link) => { link.setAttribute('target', '_self'); }; // Observe new nodes added to the document const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === 'childList') { const links = mutation.addedNodes.flatMap((node) => { if (node.tagName === 'A') { return [node]; } return node.getElementsByTagName('a'); }); links.forEach(changeLinkTarget); } }); }); // Start observing the document observer.observe(document.documentElement, { childList: true, subtree: true, }); // Also change existing links on the page document.querySelectorAll('a').forEach(changeLinkTarget); // Wait for the page to load completely window.onload = () => { // Start observing the document after the page is loaded observer.observe(document.documentElement, { childList: true, subtree: true, }); // Also change existing links on the page after the page is loaded document.querySelectorAll('a').forEach(changeLinkTarget); }; })();