Fix image width (fix #1583)

This commit is contained in:
the1812 2021-05-06 13:54:08 +08:00
parent 0459af061a
commit 89ca3d5d07
3 changed files with 6 additions and 2 deletions

View File

@ -3,7 +3,7 @@
@namespace Bilibili-Evolved
@homepageURL https://github.com/the1812/Bilibili-Evolved
@updateURL https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@preview/min/dark.user.css
@version 1014.25.0
@version 1024.90.0
@license MIT
@author Grant Howard (https://github.com/the1812), Coulomb-G (https://github.com/Coulomb-G)
==/UserStyle== */

View File

@ -1 +1 @@
(()=>(t,e)=>{const n=/@(\d+)[Ww]_(\d+)[Hh]/;const o=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseFloat(t.imageResolutionScale);const i=["#certify-img1","#certify-img2"];const r=(t,e)=>{const n=document.createNodeIterator(t,NodeFilter.SHOW_ELEMENT,null);let o=n.nextNode();while(o){if(o instanceof HTMLElement){e(o)}o=n.nextNode()}};async function a(t){const e=(e,r)=>{const a=e(t);if(a===null){return}if(i.some((e=>t.matches(e)))){return}const s=a.match(n);if(!s){return}let[,c,l]=s;let u=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(c)>=u&&u!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",c)}c=Math.round(o*parseInt(c)).toString();l=Math.round(o*parseInt(l)).toString();t.setAttribute("data-resolution-width",c);r(t,a.replace(n,`@${c}w_${l}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))}))}const s=async()=>{r(document.body,(t=>a(t)));Observer.childListSubtree(document.body,(t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){a(t);if(t.nodeName.toUpperCase()!=="IMG"){r(t,(t=>a(t)))}}}}}))};s();e.applyStyleFromText(`\n.favInfo-box .favInfo-cover img {\n width: 100% !important;\n object-position: left !important;\n}\n.bili-avatar-img {\n width: 100% !important;\n}\n`,"image-resolution-fix");return{export:{imageResolution:a}}})();
(()=>(t,e)=>{const n=/@(\d+)[Ww]_(\d+)[Hh]/;const i=t.imageResolutionScale==="auto"?window.devicePixelRatio:parseFloat(t.imageResolutionScale);const o=["#certify-img1","#certify-img2"];const r=(t,e)=>{const n=document.createNodeIterator(t,NodeFilter.SHOW_ELEMENT,null);let i=n.nextNode();while(i){if(i instanceof HTMLElement){e(i)}i=n.nextNode()}};async function a(t){const e=(e,r)=>{const a=e(t);if(a===null){return}if(o.some((e=>t.matches(e)))){return}const s=a.match(n);if(!s){return}let[,l,c]=s;let d=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(l)>=d&&d!==0){return}if(t.getAttribute("width")===null&&t.getAttribute("height")===null){t.setAttribute("width",l)}l=Math.round(i*parseInt(l)).toString();c=Math.round(i*parseInt(c)).toString();t.setAttribute("data-resolution-width",l);r(t,a.replace(n,`@${l}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))}))}const s=async()=>{r(document.body,(t=>a(t)));Observer.childListSubtree(document.body,(t=>{for(const e of t){for(const t of e.addedNodes){if(t instanceof HTMLElement){a(t);if(t.nodeName.toUpperCase()!=="IMG"){r(t,(t=>a(t)))}}}}}))};s();e.applyStyleFromText(`\n.favInfo-box .favInfo-cover img {\n width: 100% !important;\n object-position: left !important;\n}\n.bili-avatar-img {\n width: 100% !important;\n}\n.bb-comment .sailing .sailing-img,\n.comment-bilibili-fold .sailing .sailing-img {\n width: 288px;\n}\n`,"image-resolution-fix");return{export:{imageResolution:a}}})();

View File

@ -69,6 +69,10 @@ resources.applyStyleFromText(`
.bili-avatar-img {
width: 100% !important;
}
.bb-comment .sailing .sailing-img,
.comment-bilibili-fold .sailing .sailing-img {
width: 288px;
}
`, 'image-resolution-fix')
export default {
export: { imageResolution }