超星 - 在 iframe 中原地打开收件箱通知

不再需要跳转整个页面,或者打开新窗口。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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 );
	
};