mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-22 16:07:49 +08:00
12 lines
7.7 KiB
JavaScript
12 lines
7.7 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["utils/image-resolution"]=e():t["utils/image-resolution"]=e()}(globalThis,(()=>(()=>{var t,e,n={146:(t,e,n)=>{var o=n(904),r=n(955)(o);r.push([t.id,".favInfo-box .collection-cover img,\n.favInfo-box .favInfo-cover img {\n width: 100% !important;\n object-position: left !important;\n}\n\n.bb-comment .sailing .sailing-img,\n.comment-bilibili-fold .sailing .sailing-img {\n width: 288px;\n}","",{version:3,sources:["webpack://./registry/lib/components/utils/image-resolution/fix.scss"],names:[],mappings:"AAAA;;EAEE,sBAAsB;EACtB,gCAAgC;AAClC;;AAEA;;EAEE,YAAY;AACd",sourcesContent:[".favInfo-box .collection-cover img,\n.favInfo-box .favInfo-cover img {\n width: 100% !important;\n object-position: left !important;\n}\n\n.bb-comment .sailing .sailing-img,\n.comment-bilibili-fold .sailing .sailing-img {\n width: 288px;\n}"],sourceRoot:""}]),t.exports=r},955:t=>{"use strict";
|
|
// eslint-disable-next-line func-names
|
|
t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=t(e);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},
|
|
// eslint-disable-next-line func-names
|
|
e.i=function(t,n,o){"string"==typeof t&&(
|
|
// eslint-disable-next-line no-param-reassign
|
|
t=[[null,t,""]]);var r={};if(o)for(var i=0;i<this.length;i++){
|
|
// eslint-disable-next-line prefer-destructuring
|
|
var a=this[i][0];null!=a&&(r[a]=!0)}for(var s=0;s<t.length;s++){var c=[].concat(t[s]);o&&r[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),e.push(c))}},e}},904:t=>{"use strict";function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=t&&("undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"]);if(null==n)return;var o,r,i=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(o=n.next()).done)&&(i.push(o.value),!e||i.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);"Object"===o&&t.constructor&&(o=t.constructor.name);if("Map"===o||"Set"===o)return Array.from(t);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return n(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}t.exports=function(t){var n=e(t,4),o=n[1],r=n[3];if(!r)return o;if("function"==typeof btoa){
|
|
// eslint-disable-next-line no-undef
|
|
var i=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),a="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(a," */"),c=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(t," */")}));return[o].concat(c).concat([s]).join("\n")}return[o].join("\n")}},208:(t,e,n)=>{var o=n(146);o&&o.__esModule&&(o=o.default),t.exports="string"==typeof o?o:o.toString()},288:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=288,t.exports=e},903:t=>{"use strict";t.exports="对 200% 以上的屏幕 DPI 缩放请求更高分辨率的图片, 加载时间也会相应变长一些. (也会导致某些浏览器里出现图片闪动, 因为本质上是更换了图片源)\n\n由于 b 站在很多地方没有设置图片维持原比例, 如果计算后的图片尺寸超出原图尺寸则会产生错误的比例, 可以考虑在选项中手动降低缩放级别.\n\n`缩放级别` 选项:\n- `auto`: 根据 DPI 缩放超出 200% 的比例自动计算, 例如 250% 的缩放下会请求 1.5 倍尺寸的图片.\n- `数字`: 自定义尺寸的缩放倍率.\n"},104:t=>{"use strict";t.exports=coreApis.observer}},o={};function r(t){var e=o[t];if(void 0!==e)return e.exports;var i=o[t]={id:t,exports:{}};return n[t](i,i.exports,r),i.exports}e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,r.t=function(n,o){if(1&o&&(n=this(n)),8&o)return n;if("object"==typeof n&&n){if(4&o&&n.__esModule)return n;if(16&o&&"function"==typeof n.then)return n}var i=Object.create(null);r.r(i);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&o&&n;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach((t=>a[t]=()=>n[t]));return a.default=()=>n,r.d(i,a),i},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.d(i,{component:()=>p});const t=coreApis.componentApis.define,e=coreApis.componentApis.styledComponent,n=/@(\d+)[Ww](_(\d+)[Hh])?/,o=["#certify-img1","#certify-img2"],a=[".bili-avatar-img"],s=[".logo-img"],c=[".article-detail .article-content img"],l=(t,e)=>{const n=document.createNodeIterator(t,NodeFilter.SHOW_ELEMENT);let o=n.nextNode();for(;o;)e(o),o=n.nextNode()},u=async(t,e)=>{const{attributes:i}=await Promise.resolve().then(r.t.bind(r,104,23)),c=(r,i)=>{const c=r(t);if(null===c)return;if(o.some((e=>t.matches(e))))return;if(c.includes(","))return;const l=c.match(n);if(!l)return;const[,u,,d]=l,f=parseInt(t.getAttribute("data-resolution-width")||"0");if(parseInt(u)>=f&&0!==f)return;null===t.getAttribute("width")&&null===t.getAttribute("height")&&void 0!==d&&(s.some((e=>t.matches(e)))?(t.setAttribute("height",d),t.setAttribute("width",u)):a.some((e=>t.matches(e)))?t.setAttribute("height",d):t.setAttribute("width",u));const p=(t,e)=>t===1/0||e===1/0?c.replace(n,"@"):void 0===e?c.replace(n,`@${t}w`):c.replace(n,`@${t}w_${e}h`);if(void 0!==d){const n=e.getWidth(parseInt(u),t),o=e.getHeight(parseInt(d),t);t.setAttribute("data-resolution-width",n.toString()),i(t,p(n,o))}else{const n=e.getWidth(parseInt(u),t);t.setAttribute("data-resolution-width",n.toString()),i(t,p(n))}};i(t,(()=>{c((t=>t.getAttribute("src")),((t,e)=>t.setAttribute("src",e))),c((t=>t.getAttribute("srcset")),((t,e)=>t.setAttribute("srcset",e))),c((t=>t.style.backgroundImage),((t,e)=>t.style.backgroundImage=e))}))},d=(0,e.styledComponentEntry)((()=>Promise.resolve().then(r.t.bind(r,208,23))),(async t=>{let{settings:e}=t;const{allMutations:n}=await Promise.resolve().then(r.t.bind(r,104,23)),o="auto"===e.options.scale?window.devicePixelRatio<=2?1:window.devicePixelRatio/2:parseFloat(e.options.scale);if(1===o)return;const i={getWidth:(t,n)=>e.options.originalImageInArticles&&c.some((t=>n.matches(t)))?1/0:Math.round(o*t),getHeight:(t,n)=>e.options.originalImageInArticles&&c.some((t=>n.matches(t)))?1/0:Math.round(o*t)};l(document.body,(t=>u(t,i))),n((t=>{t.forEach((t=>t.addedNodes.forEach((t=>{t instanceof HTMLElement&&(u(t,i),"IMG"!==t.nodeName.toUpperCase()&&l(t,(t=>u(t,i))))}))))}))})),f=(0,t.defineOptionsMetadata)({scale:{displayName:"缩放级别",defaultValue:"auto"},originalImageInArticles:{displayName:"在专栏中请求原图",defaultValue:!1}}),p=(0,t.defineComponentMetadata)({name:"imageResolution",displayName:"高分辨率图片",tags:[componentsTags.utils],enabledByDefault:window.devicePixelRatio>1,entry:d,options:f,commitHash:"d87d69cfb9d7e0124bd90a06fec4569bd61e02c5",coreVersion:"2.10.7",description:(()=>{const t=r(288);return{...Object.fromEntries(t.keys().map((e=>[e.match(/index\.(.+)\.md$/)[1],t(e)]))),"zh-CN":()=>Promise.resolve().then(r.t.bind(r,903,17)).then((t=>t.default))}})()})})(),i=i.component})()));
|
|
//# sourceMappingURL=https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/registry/dist/components/utils/image-resolution.js.map
|