File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1161,11 +1161,34 @@ function removeLogin() {
11611161// 净化标题消息
11621162function cleanTitles ( ) {
11631163 if ( ! menu_value ( 'menu_cleanTitles' ) ) return
1164- Object . defineProperty ( document , 'title' , {
1165- set : function ( value ) {
1166- //console.log(value);
1164+
1165+ // 方案一
1166+ const elTitle = document . head . querySelector ( 'title' ) ;
1167+ const original = elTitle . textContent ;
1168+ const observer = new MutationObserver ( function ( ) {
1169+ if ( elTitle . textContent != original ) { // 避免重复执行
1170+ elTitle . textContent = original ;
11671171 }
11681172 } ) ;
1173+ observer . observe ( elTitle , { childList : true } ) ;
1174+
1175+ // 方案二
1176+ // if (Reflect.getOwnPropertyDescriptor(document, 'title')) {
1177+ // const elTitle = document.head.querySelector('title');
1178+ // const original = elTitle.textContent;
1179+ // const observer = new MutationObserver(function() {
1180+ // if (elTitle.textContent != original) { // 避免重复执行
1181+ // elTitle.textContent = original;
1182+ // }
1183+ // });
1184+ // observer.observe(elTitle, { childList: true });
1185+ // } else {
1186+ // const title = document.title;
1187+ // Reflect.defineProperty(document, 'title', {
1188+ // set: () => {},
1189+ // get: () => title,
1190+ // });
1191+ // }
11691192}
11701193
11711194
You can’t perform that action at this time.
0 commit comments