mirror of
https://github.com/XIU2/UserScript.git
synced 2026-09-22 15:06:57 +00:00
新增 [宽屏显示] 脚本菜单
This commit is contained in:
@@ -18,28 +18,34 @@
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
var menu_postimg = GM_getValue('xiu2_menu_postimg'),
|
||||
var menu_widescreenDisplay = GM_getValue('xiu2_menu_widescreenDisplay'),
|
||||
menu_postimg = GM_getValue('xiu2_menu_postimg'),
|
||||
menu_hideTitle = GM_getValue('xiu2_menu_hideTitle'),
|
||||
menu_postimg_ID, menu_hideTitle_ID, menu_feedBack_ID;
|
||||
if (menu_postimg == null){menu_postimg = false; GM_setValue('xiu2_menu_postimg', menu_postimg)};
|
||||
if (menu_hideTitle == null){menu_hideTitle = false; GM_setValue('xiu2_menu_hideTitle', menu_hideTitle)};
|
||||
menu_widescreenDisplay_ID, menu_postimg_ID, menu_hideTitle_ID, menu_feedBack_ID;
|
||||
if (menu_widescreenDisplay == null){menu_widescreenDisplay = true; GM_setValue('xiu2_menu_widescreenDisplay', menu_widescreenDisplay)};
|
||||
if (menu_postimg == null){menu_postimg = true; GM_setValue('xiu2_menu_postimg', menu_postimg)};
|
||||
if (menu_hideTitle == null){menu_hideTitle = true; GM_setValue('xiu2_menu_hideTitle', menu_hideTitle)};
|
||||
registerMenuCommand();
|
||||
addStyle();
|
||||
|
||||
// 注册脚本菜单
|
||||
function registerMenuCommand() {
|
||||
let menu_postimg_, menu_hideTitle_;
|
||||
let menu_widescreenDisplay_, menu_postimg_, menu_hideTitle_;
|
||||
if (menu_feedBack_ID){ // 如果反馈菜单ID不是 null,则删除所有脚本菜单
|
||||
GM_unregisterMenuCommand(menu_widescreenDisplay_ID);
|
||||
GM_unregisterMenuCommand(menu_postimg_ID);
|
||||
GM_unregisterMenuCommand(menu_hideTitle_ID);
|
||||
GM_unregisterMenuCommand(menu_feedBack_ID);
|
||||
menu_widescreenDisplay = GM_getValue('xiu2_menu_widescreenDisplay');
|
||||
menu_postimg = GM_getValue('xiu2_menu_postimg');
|
||||
menu_hideTitle = GM_getValue('xiu2_menu_hideTitle');
|
||||
}
|
||||
|
||||
if (menu_widescreenDisplay){menu_widescreenDisplay_ = "√";}else{menu_widescreenDisplay_ = "×";}
|
||||
if (menu_postimg){menu_postimg_ = "√";}else{menu_postimg_ = "×";}
|
||||
if (menu_hideTitle){menu_hideTitle_ = "√";}else{menu_hideTitle_ = "×";}
|
||||
|
||||
menu_widescreenDisplay_ID = GM_registerMenuCommand(`[ ${menu_widescreenDisplay_} ] 宽屏显示`, function(){menu_switch(menu_widescreenDisplay,'xiu2_menu_widescreenDisplay','宽屏显示')});
|
||||
menu_postimg_ID = GM_registerMenuCommand(`[ ${menu_postimg_} ] 隐藏文章开头大图`, function(){menu_switch(menu_postimg,'xiu2_menu_postimg','隐藏文章开头大图')});
|
||||
menu_hideTitle_ID = GM_registerMenuCommand(`[ ${menu_hideTitle_} ] 隐藏浏览回答标题`, function(){menu_switch(menu_hideTitle,'xiu2_menu_hideTitle','隐藏浏览回答标题')});
|
||||
menu_feedBack_ID = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});});
|
||||
@@ -60,8 +66,8 @@
|
||||
|
||||
// 添加样式
|
||||
function addStyle() {
|
||||
let style,
|
||||
style_1 = `
|
||||
let style = ``,
|
||||
style_1 = `/* 宽屏显示 */
|
||||
.GlobalSideBar,.Question-sideColumn,.ContentLayout-sideColumn,.SearchSideBar,.Card.QuestionHeaderTopicMeta {
|
||||
display: none !important;
|
||||
}
|
||||
@@ -78,7 +84,8 @@
|
||||
style_2 = `/* 隐藏在各列表中查看文章时开头显示的大图,不影响文章、专栏页面 */
|
||||
.RichContent img.ArticleItem-image {
|
||||
display: none !important;
|
||||
}`,
|
||||
}
|
||||
`,
|
||||
style_3 = `/* 调整文章编辑页面与实际文章宽度一致 */
|
||||
.PostEditor .RichText {
|
||||
min-width: 690px !important;
|
||||
@@ -87,14 +94,18 @@
|
||||
.WriteIndex-titleInput .Input {
|
||||
min-width: 690px !important;
|
||||
font-size: 24px;
|
||||
}`,
|
||||
}
|
||||
`,
|
||||
style_4 = `/* 浏览回答时,向下翻隐藏顶栏(问题的标题)*/
|
||||
header.is-hidden {
|
||||
display: none;
|
||||
}`
|
||||
}
|
||||
`
|
||||
let style_Add = document.createElement('style');
|
||||
// 宽屏显示
|
||||
style = style_1;
|
||||
if (menu_widescreenDisplay) {
|
||||
style += style_1;
|
||||
}
|
||||
// 隐藏文章开头大图
|
||||
if (menu_postimg) {
|
||||
style += style_2;
|
||||
|
||||
Reference in New Issue
Block a user