diff --git a/README.md b/README.md index ffbe5b302..d040a0f5b 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ 根据屏幕DPI请求更高分辨率的图片, 例如DPI缩放200%则请求2倍的分辨率, 加载时间也会相应变长一些. 适用于2K, 4K等的显示屏, DPI缩放为100%的用户不需要此功能. -; + ### 旧版动态跳转支持 将新版动态的链接换为旧版动态, 同时可在附加功能中在新旧动态间切换. diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 294d9c135..d502b121c 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 278.17 +// @version 278.79 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -948,7 +948,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/i18n.min.js"] = (()=>{return(e,t)=>{const a={"日本語":"ja-JP",English:"en-US",Deutsch:"de-DE"};class s{accepts(e){return e.nodeType===Node.ELEMENT_NODE}getValue(e){return e.nodeValue}setValue(e,t){e.nodeValue=t}getElement(e){return e}translate(e){const t=this.getValue(e);if(!t||typeof t!=="string"||t==="*"){return}const a=s.map.get(t.trim());if(a===undefined){const a=s.regex.find(([e])=>e.test(t));if(a){const[s,r]=a;this.setValue(e,t.replace(s,r))}}else if(typeof a==="string"){this.setValue(e,a)}else if(Array.isArray(a)){let t=null;for(const s of a){if(typeof s==="string"){t=s}else{const{text:a,selector:r,not:n}=s;if(this.getElement(e).matches(r)!==Boolean(n)){t=a}}}if(t!==null){this.setValue(e,t)}}else{const{text:t,selector:s,not:r}=a;if(this.getElement(e).matches(s)!==Boolean(r)){this.setValue(e,t)}}}static walk(e,t){const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null,false);let s=a.nextNode();while(s){t(s);s=a.nextNode()}}static translate(e){if(e.nodeType===Node.TEXT_NODE){s.textNode.translate(e);return}s.walk(e,e=>{for(const t of s.allTranslators){if(t.accepts(e)){t.translate(e)}}})}static translateCssMatches(){const e=s.map.get("*");if(!e){return}for(const{selector:t,text:a}of e){const e=document.querySelector(t);if(e){[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE).forEach(e=>e.nodeValue=a)}}}}class r extends s{accepts(e){return e.nodeType===Node.TEXT_NODE}getElement(e){return e.parentElement}}class n extends s{getValue(e){return e.getAttribute("title")}setValue(e,t){e.setAttribute("title",t)}}class l extends s{getValue(e){return e.getAttribute("placeholder")}setValue(e,t){e.setAttribute("placeholder",t)}}s.textNode=new r;s.title=new n;s.placeholder=new l;s.allTranslators=[s.textNode,s.title,s.placeholder];(async()=>{const r=a[e.i18nLanguage];const{map:n,regex:l}=await t.importAsync(`i18n.${r}`);document.documentElement.setAttribute("lang",r);s.map=n;s.regex=[...l.entries()];s.translate(document.body);s.translateCssMatches();Observer.observe("body",e=>{e.forEach(e=>{if(e.type==="childList"){if(e.addedNodes.length>0){s.translateCssMatches()}e.addedNodes.forEach(e=>{s.translate(e)})}else if(e.type==="characterData"){s.textNode.translate(e.target)}})},{characterData:true,childList:true,subtree:true})})();return{export:{Translator:s,TextNodeTranslator:r,TitleTranslator:n,PlaceholderTranslator:l},dropdown:{key:"i18nLanguage",items:[`日本語`]}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/i18n.zh-TW.min.js"] = (()=>{return(r,e)=>{const n=new Map([[`主站`,`主站`],[`画友`,`絵画`],[`音频`,`音樂`],[`游戏中心`,`遊戲`],[`会员购`,`購物`],[`漫画`,`漫畫`],[`下载APP`,`下載APP`],[`大会员`,`大會員`],[`动态`,`動態`],[`稍后再看`,`稍後再看`],[`历史`,`歷史`],[`番剧`,`番劇`],[`动画`,`動畫`],[`国创`,`國創`],[`音乐`,`音樂`],[`游戏`,`遊戲`],[`数码`,`數位`],[`电影`,`電影`],[`纪录片`,`紀錄片`],[`时尚`,`時尚`],[`娱乐`,`娛樂`],[`广告`,`廣告`],[`原创`,`原創`],[`广场`,`廣場`],[`发布`,`發佈`],[`专栏`,`專欄`],[`关注`,`關注`],[`粉丝`,`粉絲`],[`热门`,`熱門`],[`视频`,`影片`],[`图片`,`圖片`],[`小视频`,`短影片`],[`公告栏`,`公告欄`],[`特别推荐`,`特別推薦`],[`有新动态`,`有新動態`],[`所有关注`,`所有關注`],[`首页`,`首頁`],[`编辑`,`編輯`],[`回复`,`回覆`],[`举报`,`舉報`],[`在线人数`,`在線人數`],[`*`,[]]]);return{export:{map:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/icons.min.css"] = `.icons-enabled [class^=icon-]{width:24px;height:24px;display:inline-block;background-image:none}.icons-enabled [class^=icon-]::after{content:"";width:24px;height:24px;display:inline-block}.icons-enabled .icon-view::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-clear::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-download::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-update::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-info::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-settings::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-widgets::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-cancel::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-ok::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-video::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-style::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-tool::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-touch::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-other::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-arrow::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-rank::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-like::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-danmaku::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-search::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu>li.home>a,.icons-enabled .icon-home::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.zhuanlan,.icons-enabled .icon-read::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.square,.icons-enabled .icon-square::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.live,.icons-enabled .icon-live::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.blackroom,.icons-enabled .icon-judge::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-medal::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-live-title::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-biliplus::after{background-image:url('data:image/svg+xml;utf-8,')}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-resolution.min.js"] = (()=>{return(t,e)=>{const r=/@(\d+)[Ww]_(\d+)[Hh]/;const n=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseInt(t.imageResolutionScale);const o=["#certify-img1","#certify-img2"];const i=(t,e)=>{const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,false);let n=r.nextNode();while(n){e(n);n=r.nextNode()}};async function s(t){const e=(e,i)=>{const s=e(t);if(s===null){return}if(o.some(e=>t.matches(e))){return}const a=s.match(r);if(!a){return}let[,u,c]=a;let l=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=l&&l!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",u)}u=(n*parseInt(u)).toString();c=(n*parseInt(c)).toString();t.setAttribute("data-resolution-width",u);i(t,s.replace(r,`@${u}w_${c}h`))};Observer.attributes(t,()=>{e(t=>t.getAttribute("src"),(t,e)=>t.setAttribute("src",e));e(t=>t.style.backgroundImage,(t,e)=>t.style.backgroundImage=e)})}i(document.body,t=>s(t));Observer.childListSubtree(document.body,t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){s(t);if(t.nodeName.toUpperCase()!=="IMG"){i(t,t=>s(t))}}}}});return{export:{imageResolution:s}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-resolution.min.js"] = (()=>{return(t,e)=>{const r=/@(\d+)[Ww]_(\d+)[Hh]/;const o=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseFloat(t.imageResolutionScale);const n=["#certify-img1","#certify-img2"];const i=(t,e)=>{const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,false);let o=r.nextNode();while(o){e(o);o=r.nextNode()}};async function s(t){const e=(e,i)=>{const s=e(t);if(s===null){return}if(n.some(e=>t.matches(e))){return}const a=s.match(r);if(!a){return}let[,u,c]=a;let l=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=l&&l!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",u)}u=Math.round(o*parseInt(u)).toString();c=Math.round(o*parseInt(c)).toString();t.setAttribute("data-resolution-width",u);i(t,s.replace(r,`@${u}w_${c}h`))};Observer.attributes(t,()=>{e(t=>t.getAttribute("src"),(t,e)=>t.setAttribute("src",e));e(t=>t.style.backgroundImage,(t,e)=>t.style.backgroundImage=e)})}i(document.body,t=>s(t));Observer.childListSubtree(document.body,t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){s(t);if(t.nodeName.toUpperCase()!=="IMG"){i(t,t=>s(t))}}}}});return{export:{imageResolution:s}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-viewer.min.css"] = `body.image-viewer-opened,html.image-viewer-opened{overflow:hidden!important}.image-viewer-container{background:rgba(0,0,0,.85);width:100%;height:100%;position:fixed;top:0;left:0;z-index:100000;display:none;justify-content:center;align-items:center}.image-viewer-container.opened{display:flex}.image-viewer{width:90%;height:90%;display:grid;grid-template-columns:auto 48px;grid-template-rows:48px auto 48px 12px 48px 18px 48px;grid-template-areas:"image close" "image ." "image copy-link" "image ." "image new-tab" "image ." "image download";grid-column-gap:12px;justify-items:center;justify-content:stretch;align-items:center;align-content:stretch}.image-viewer .image{grid-area:image;width:auto;height:auto;max-width:100%;max-height:100%}.image-viewer .close{grid-area:close}.image-viewer .download{grid-area:download}.image-viewer .copy-link{grid-area:copy-link;transform:scale(.95)}.image-viewer .new-tab{grid-area:new-tab;transform:scale(.85)}.image-viewer-icon{cursor:pointer;width:100%;height:100%}.image-viewer-icon svg{max-width:48px;max-height:48px}.image-viewer-icon path{fill:#eee;transition:.2s;transform-origin:center}.image-viewer-icon:hover path{fill:var(--theme-color);transform:scale(1.1)}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-viewer.min.html"] = `
`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.css"] = `.medal-popup{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);left:50%;background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:100}.medal-popup.opened{transform:scaleY(1) translateX(-50%)}.medal-popup *{transition:.2s}.medal-popup ul{list-style:none;margin:0;padding:0}.medal-popup ul>li.active{box-shadow:0 0 4px 0 var(--theme-color)}.medal-popup ul>li:hover{background-color:rgba(0,0,0,.16)}.medal-popup label{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:8px}.medal-popup label>*{flex-shrink:0}.medal-popup input[type=radio]{visibility:collapse;width:0;margin:0;padding:0}.medal-popup input[type=radio]~i{opacity:0;transform:scale(.8);margin:0}.medal-popup input[type=radio]~.fans-medal-item{margin:0 8px}.medal-popup input[type=radio]:checked~i{opacity:1}.title-image{display:inline-block;vertical-align:middle;height:20px}.fans-medal-item .label{width:40px;text-align:center;padding:0 2px;color:#fff}.fans-medal-item .level{width:16px;background-color:#fff;text-align:center;color:#61decb}.fans-medal-item .label,.fans-medal-item .level{position:relative;display:block;float:left}.fans-medal-item{display:inline-block;height:14px;line-height:14px;color:#fff;border:1px solid #61decb;border-left:0;white-space:nowrap;border-radius:2px;flex-shrink:0;font-size:12px}.level-1,.level-2,.level-3,.level-4{border-color:#61decb}.level-1 .label,.level-2 .label,.level-3 .label,.level-4 .label{background-color:#61decb}.level-1 .level,.level-2 .level,.level-3 .level,.level-4 .level{color:#61decb}.level-5,.level-6,.level-7,.level-8{border-color:#5896de}.level-5 .label,.level-6 .label,.level-7 .label,.level-8 .label{background-color:#5896de}.level-5 .level,.level-6 .level,.level-7 .level,.level-8 .level{color:#5896de}.level-10,.level-11,.level-12,.level-9{border-color:#a068f1}.level-10 .label,.level-11 .label,.level-12 .label,.level-9 .label{background-color:#a068f1}.level-10 .level,.level-11 .level,.level-12 .level,.level-9 .level{color:#a068f1}.level-13,.level-14,.level-15,.level-16{border-color:#ff86b2}.level-13 .label,.level-14 .label,.level-15 .label,.level-16 .label{background-color:#ff86b2}.level-13 .level,.level-14 .level,.level-15 .level,.level-16 .level{color:#ff86b2}.level-17,.level-18,.level-19,.level-20{border-color:#f6be18}.level-17 .label,.level-18 .label,.level-19 .label,.level-20 .label{background-color:#f6be18}.level-17 .level,.level-18 .level,.level-19 .level,.level-20 .level{color:#f6be18}`; diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index d2605bac4..f86935489 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview Offline) -// @version 278.17 +// @version 278.79 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -948,7 +948,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/i18n.min.js"] = (()=>{return(e,t)=>{const a={"日本語":"ja-JP",English:"en-US",Deutsch:"de-DE"};class s{accepts(e){return e.nodeType===Node.ELEMENT_NODE}getValue(e){return e.nodeValue}setValue(e,t){e.nodeValue=t}getElement(e){return e}translate(e){const t=this.getValue(e);if(!t||typeof t!=="string"||t==="*"){return}const a=s.map.get(t.trim());if(a===undefined){const a=s.regex.find(([e])=>e.test(t));if(a){const[s,r]=a;this.setValue(e,t.replace(s,r))}}else if(typeof a==="string"){this.setValue(e,a)}else if(Array.isArray(a)){let t=null;for(const s of a){if(typeof s==="string"){t=s}else{const{text:a,selector:r,not:n}=s;if(this.getElement(e).matches(r)!==Boolean(n)){t=a}}}if(t!==null){this.setValue(e,t)}}else{const{text:t,selector:s,not:r}=a;if(this.getElement(e).matches(s)!==Boolean(r)){this.setValue(e,t)}}}static walk(e,t){const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,null,false);let s=a.nextNode();while(s){t(s);s=a.nextNode()}}static translate(e){if(e.nodeType===Node.TEXT_NODE){s.textNode.translate(e);return}s.walk(e,e=>{for(const t of s.allTranslators){if(t.accepts(e)){t.translate(e)}}})}static translateCssMatches(){const e=s.map.get("*");if(!e){return}for(const{selector:t,text:a}of e){const e=document.querySelector(t);if(e){[...e.childNodes].filter(e=>e.nodeType===Node.TEXT_NODE).forEach(e=>e.nodeValue=a)}}}}class r extends s{accepts(e){return e.nodeType===Node.TEXT_NODE}getElement(e){return e.parentElement}}class n extends s{getValue(e){return e.getAttribute("title")}setValue(e,t){e.setAttribute("title",t)}}class l extends s{getValue(e){return e.getAttribute("placeholder")}setValue(e,t){e.setAttribute("placeholder",t)}}s.textNode=new r;s.title=new n;s.placeholder=new l;s.allTranslators=[s.textNode,s.title,s.placeholder];(async()=>{const r=a[e.i18nLanguage];const{map:n,regex:l}=await t.importAsync(`i18n.${r}`);document.documentElement.setAttribute("lang",r);s.map=n;s.regex=[...l.entries()];s.translate(document.body);s.translateCssMatches();Observer.observe("body",e=>{e.forEach(e=>{if(e.type==="childList"){if(e.addedNodes.length>0){s.translateCssMatches()}e.addedNodes.forEach(e=>{s.translate(e)})}else if(e.type==="characterData"){s.textNode.translate(e.target)}})},{characterData:true,childList:true,subtree:true})})();return{export:{Translator:s,TextNodeTranslator:r,TitleTranslator:n,PlaceholderTranslator:l},dropdown:{key:"i18nLanguage",items:[`日本語`]}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/i18n.zh-TW.min.js"] = (()=>{return(r,e)=>{const n=new Map([[`主站`,`主站`],[`画友`,`絵画`],[`音频`,`音樂`],[`游戏中心`,`遊戲`],[`会员购`,`購物`],[`漫画`,`漫畫`],[`下载APP`,`下載APP`],[`大会员`,`大會員`],[`动态`,`動態`],[`稍后再看`,`稍後再看`],[`历史`,`歷史`],[`番剧`,`番劇`],[`动画`,`動畫`],[`国创`,`國創`],[`音乐`,`音樂`],[`游戏`,`遊戲`],[`数码`,`數位`],[`电影`,`電影`],[`纪录片`,`紀錄片`],[`时尚`,`時尚`],[`娱乐`,`娛樂`],[`广告`,`廣告`],[`原创`,`原創`],[`广场`,`廣場`],[`发布`,`發佈`],[`专栏`,`專欄`],[`关注`,`關注`],[`粉丝`,`粉絲`],[`热门`,`熱門`],[`视频`,`影片`],[`图片`,`圖片`],[`小视频`,`短影片`],[`公告栏`,`公告欄`],[`特别推荐`,`特別推薦`],[`有新动态`,`有新動態`],[`所有关注`,`所有關注`],[`首页`,`首頁`],[`编辑`,`編輯`],[`回复`,`回覆`],[`举报`,`舉報`],[`在线人数`,`在線人數`],[`*`,[]]]);return{export:{map:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/icons.min.css"] = `.icons-enabled [class^=icon-]{width:24px;height:24px;display:inline-block;background-image:none}.icons-enabled [class^=icon-]::after{content:"";width:24px;height:24px;display:inline-block}.icons-enabled .icon-view::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-clear::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-download::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-update::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-info::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-settings::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-widgets::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-cancel::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-ok::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-video::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-style::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-tool::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-touch::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-other::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-arrow::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-rank::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-like::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-danmaku::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-search::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu>li.home>a,.icons-enabled .icon-home::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.zhuanlan,.icons-enabled .icon-read::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.square,.icons-enabled .icon-square::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.live,.icons-enabled .icon-live::after{background-image:url('data:image/svg+xml;utf-8,')}.compact .primary-menu .nav-menu .side-nav .side-link i.blackroom,.icons-enabled .icon-judge::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-medal::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-live-title::after{background-image:url('data:image/svg+xml;utf-8,')}.icons-enabled .icon-biliplus::after{background-image:url('data:image/svg+xml;utf-8,')}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-resolution.min.js"] = (()=>{return(t,e)=>{const r=/@(\d+)[Ww]_(\d+)[Hh]/;const n=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseInt(t.imageResolutionScale);const o=["#certify-img1","#certify-img2"];const i=(t,e)=>{const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,false);let n=r.nextNode();while(n){e(n);n=r.nextNode()}};async function s(t){const e=(e,i)=>{const s=e(t);if(s===null){return}if(o.some(e=>t.matches(e))){return}const a=s.match(r);if(!a){return}let[,u,c]=a;let l=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=l&&l!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",u)}u=(n*parseInt(u)).toString();c=(n*parseInt(c)).toString();t.setAttribute("data-resolution-width",u);i(t,s.replace(r,`@${u}w_${c}h`))};Observer.attributes(t,()=>{e(t=>t.getAttribute("src"),(t,e)=>t.setAttribute("src",e));e(t=>t.style.backgroundImage,(t,e)=>t.style.backgroundImage=e)})}i(document.body,t=>s(t));Observer.childListSubtree(document.body,t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){s(t);if(t.nodeName.toUpperCase()!=="IMG"){i(t,t=>s(t))}}}}});return{export:{imageResolution:s}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-resolution.min.js"] = (()=>{return(t,e)=>{const r=/@(\d+)[Ww]_(\d+)[Hh]/;const o=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseFloat(t.imageResolutionScale);const n=["#certify-img1","#certify-img2"];const i=(t,e)=>{const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,false);let o=r.nextNode();while(o){e(o);o=r.nextNode()}};async function s(t){const e=(e,i)=>{const s=e(t);if(s===null){return}if(n.some(e=>t.matches(e))){return}const a=s.match(r);if(!a){return}let[,u,c]=a;let l=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=l&&l!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",u)}u=Math.round(o*parseInt(u)).toString();c=Math.round(o*parseInt(c)).toString();t.setAttribute("data-resolution-width",u);i(t,s.replace(r,`@${u}w_${c}h`))};Observer.attributes(t,()=>{e(t=>t.getAttribute("src"),(t,e)=>t.setAttribute("src",e));e(t=>t.style.backgroundImage,(t,e)=>t.style.backgroundImage=e)})}i(document.body,t=>s(t));Observer.childListSubtree(document.body,t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){s(t);if(t.nodeName.toUpperCase()!=="IMG"){i(t,t=>s(t))}}}}});return{export:{imageResolution:s}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-viewer.min.css"] = `body.image-viewer-opened,html.image-viewer-opened{overflow:hidden!important}.image-viewer-container{background:rgba(0,0,0,.85);width:100%;height:100%;position:fixed;top:0;left:0;z-index:100000;display:none;justify-content:center;align-items:center}.image-viewer-container.opened{display:flex}.image-viewer{width:90%;height:90%;display:grid;grid-template-columns:auto 48px;grid-template-rows:48px auto 48px 12px 48px 18px 48px;grid-template-areas:"image close" "image ." "image copy-link" "image ." "image new-tab" "image ." "image download";grid-column-gap:12px;justify-items:center;justify-content:stretch;align-items:center;align-content:stretch}.image-viewer .image{grid-area:image;width:auto;height:auto;max-width:100%;max-height:100%}.image-viewer .close{grid-area:close}.image-viewer .download{grid-area:download}.image-viewer .copy-link{grid-area:copy-link;transform:scale(.95)}.image-viewer .new-tab{grid-area:new-tab;transform:scale(.85)}.image-viewer-icon{cursor:pointer;width:100%;height:100%}.image-viewer-icon svg{max-width:48px;max-height:48px}.image-viewer-icon path{fill:#eee;transition:.2s;transform-origin:center}.image-viewer-icon:hover path{fill:var(--theme-color);transform:scale(1.1)}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-viewer.min.html"] = ``; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.css"] = `.medal-popup{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);left:50%;background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:100}.medal-popup.opened{transform:scaleY(1) translateX(-50%)}.medal-popup *{transition:.2s}.medal-popup ul{list-style:none;margin:0;padding:0}.medal-popup ul>li.active{box-shadow:0 0 4px 0 var(--theme-color)}.medal-popup ul>li:hover{background-color:rgba(0,0,0,.16)}.medal-popup label{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:8px}.medal-popup label>*{flex-shrink:0}.medal-popup input[type=radio]{visibility:collapse;width:0;margin:0;padding:0}.medal-popup input[type=radio]~i{opacity:0;transform:scale(.8);margin:0}.medal-popup input[type=radio]~.fans-medal-item{margin:0 8px}.medal-popup input[type=radio]:checked~i{opacity:1}.title-image{display:inline-block;vertical-align:middle;height:20px}.fans-medal-item .label{width:40px;text-align:center;padding:0 2px;color:#fff}.fans-medal-item .level{width:16px;background-color:#fff;text-align:center;color:#61decb}.fans-medal-item .label,.fans-medal-item .level{position:relative;display:block;float:left}.fans-medal-item{display:inline-block;height:14px;line-height:14px;color:#fff;border:1px solid #61decb;border-left:0;white-space:nowrap;border-radius:2px;flex-shrink:0;font-size:12px}.level-1,.level-2,.level-3,.level-4{border-color:#61decb}.level-1 .label,.level-2 .label,.level-3 .label,.level-4 .label{background-color:#61decb}.level-1 .level,.level-2 .level,.level-3 .level,.level-4 .level{color:#61decb}.level-5,.level-6,.level-7,.level-8{border-color:#5896de}.level-5 .label,.level-6 .label,.level-7 .label,.level-8 .label{background-color:#5896de}.level-5 .level,.level-6 .level,.level-7 .level,.level-8 .level{color:#5896de}.level-10,.level-11,.level-12,.level-9{border-color:#a068f1}.level-10 .label,.level-11 .label,.level-12 .label,.level-9 .label{background-color:#a068f1}.level-10 .level,.level-11 .level,.level-12 .level,.level-9 .level{color:#a068f1}.level-13,.level-14,.level-15,.level-16{border-color:#ff86b2}.level-13 .label,.level-14 .label,.level-15 .label,.level-16 .label{background-color:#ff86b2}.level-13 .level,.level-14 .level,.level-15 .level,.level-16 .level{color:#ff86b2}.level-17,.level-18,.level-19,.level-20{border-color:#f6be18}.level-17 .label,.level-18 .label,.level-19 .label,.level-20 .label{background-color:#f6be18}.level-17 .level,.level-18 .level,.level-19 .level,.level-20 .level{color:#f6be18}`; diff --git a/min/image-resolution.min.js b/min/image-resolution.min.js index 00a39288e..62b678b89 100644 --- a/min/image-resolution.min.js +++ b/min/image-resolution.min.js @@ -1 +1 @@ -(()=>{return(t,e)=>{const r=/@(\d+)[Ww]_(\d+)[Hh]/;const n=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseInt(t.imageResolutionScale);const o=["#certify-img1","#certify-img2"];const i=(t,e)=>{const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,false);let n=r.nextNode();while(n){e(n);n=r.nextNode()}};async function s(t){const e=(e,i)=>{const s=e(t);if(s===null){return}if(o.some(e=>t.matches(e))){return}const a=s.match(r);if(!a){return}let[,u,c]=a;let l=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=l&&l!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",u)}u=(n*parseInt(u)).toString();c=(n*parseInt(c)).toString();t.setAttribute("data-resolution-width",u);i(t,s.replace(r,`@${u}w_${c}h`))};Observer.attributes(t,()=>{e(t=>t.getAttribute("src"),(t,e)=>t.setAttribute("src",e));e(t=>t.style.backgroundImage,(t,e)=>t.style.backgroundImage=e)})}i(document.body,t=>s(t));Observer.childListSubtree(document.body,t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){s(t);if(t.nodeName.toUpperCase()!=="IMG"){i(t,t=>s(t))}}}}});return{export:{imageResolution:s}}}})(); \ No newline at end of file +(()=>{return(t,e)=>{const r=/@(\d+)[Ww]_(\d+)[Hh]/;const o=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseFloat(t.imageResolutionScale);const n=["#certify-img1","#certify-img2"];const i=(t,e)=>{const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,false);let o=r.nextNode();while(o){e(o);o=r.nextNode()}};async function s(t){const e=(e,i)=>{const s=e(t);if(s===null){return}if(n.some(e=>t.matches(e))){return}const a=s.match(r);if(!a){return}let[,u,c]=a;let l=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=l&&l!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",u)}u=Math.round(o*parseInt(u)).toString();c=Math.round(o*parseInt(c)).toString();t.setAttribute("data-resolution-width",u);i(t,s.replace(r,`@${u}w_${c}h`))};Observer.attributes(t,()=>{e(t=>t.getAttribute("src"),(t,e)=>t.setAttribute("src",e));e(t=>t.style.backgroundImage,(t,e)=>t.style.backgroundImage=e)})}i(document.body,t=>s(t));Observer.childListSubtree(document.body,t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){s(t);if(t.nodeName.toUpperCase()!=="IMG"){i(t,t=>s(t))}}}}});return{export:{imageResolution:s}}}})(); \ No newline at end of file diff --git a/utils/image-resolution.js b/utils/image-resolution.js index 4ebcdabb1..20e0b93e8 100644 --- a/utils/image-resolution.js +++ b/utils/image-resolution.js @@ -1,5 +1,5 @@ const regex = /@(\d+)[Ww]_(\d+)[Hh]/; -const dpi = settings.imageResolutionScale === "auto" ? window.devicePixelRatio : parseInt(settings.imageResolutionScale); +const dpi = settings.imageResolutionScale === "auto" ? window.devicePixelRatio : parseFloat(settings.imageResolutionScale); const excludeSelectors = [ "#certify-img1", "#certify-img2", @@ -43,8 +43,8 @@ export async function imageResolution(element) { if (element.getAttribute("width") === null && element.getAttribute("height") === null) { element.setAttribute("width", width); } - width = (dpi * parseInt(width)).toString(); - height = (dpi * parseInt(height)).toString(); + width = Math.round(dpi * parseInt(width)).toString(); + height = Math.round(dpi * parseInt(height)).toString(); element.setAttribute("data-resolution-width", width); setValue(element, value.replace(regex, `@${width}w_${height}h`)); }; diff --git a/utils/image-resolution.ts b/utils/image-resolution.ts index b7ccf424c..d4ace4b37 100644 --- a/utils/image-resolution.ts +++ b/utils/image-resolution.ts @@ -1,5 +1,5 @@ const regex = /@(\d+)[Ww]_(\d+)[Hh]/; -const dpi = settings.imageResolutionScale === "auto" ? window.devicePixelRatio : parseInt(settings.imageResolutionScale); +const dpi = settings.imageResolutionScale === "auto" ? window.devicePixelRatio : parseFloat(settings.imageResolutionScale); const excludeSelectors = [ "#certify-img1", "#certify-img2", @@ -52,8 +52,8 @@ export async function imageResolution(element: HTMLElement) { element.setAttribute("width", width); } - width = (dpi * parseInt(width)).toString(); - height = (dpi * parseInt(height)).toString(); + width = Math.round(dpi * parseInt(width)).toString(); + height = Math.round(dpi * parseInt(height)).toString(); element.setAttribute("data-resolution-width", width); setValue(element, value.replace(regex, `@${width}w_${height}h`)); };