不再需要跳转整个页面,或者打开新窗口。
// ==UserScript== // @name 超星 - 在 iframe 中原地打开收件箱通知 // @description 不再需要跳转整个页面,或者打开新窗口。 // @namespace UnKnown // @author UnKnown // @icon https://imgsrc.baidu.com/forum/pic/item/6a63f6246b600c33c3d714d61c4c510fd9f9a106.jpg // @version 1.0 // @match http://notice.chaoxing.com/pc/notice/* // @match https://notice.chaoxing.com/pc/notice/* // @grant unsafeWindow // @inject-into page // ==/UserScript== if ( location.pathname === "/pc/notice/myNotice" ) { // Notice.openDetail(this, `/pc/notice/${ noticeID }/detail`); unsafeWindow.Notice.openDetail = function(obj, url) { url && location.assign(url); }; } else if ( location.pathname.endsWith("/detail") ) { const style = document.createElement("style"); style.textContent = `.subPageMain, .editContainer.noticeDetail_editContainer { width: auto; } .subPageMain { padding: 0 16px; } button.back { position: fixed; z-index: 11; top: 4px; right: 4px; width: 90px; height: 32px; color: white; background-color: transparent; border: 1px solid white; } button.back:hover, button.back:focus { cursor: pointer; background-color: rgba(255, 255, 255, .2); } button.back:active { background-color: rgba(255, 255, 255, .4); }`; document.head.appendChild(style); const button = document.createElement("button"); button.className = "back"; button.textContent = "返回"; button.addEventListener( "click", function () { history.back(); } ); document.body.insertBefore( button, document.body.firstChild ); };