PageSourceSearch

https://e621.net/vite/assets/ThumbnailEngine-DM3XZxn_.js

js e621.net collected 2026-09-24 18:59:53 UTC 17,016 bytes, 1 lines download raw bytes

1import{i as e,t}from"./jquery-CY-EeEkZ.js";import{t as n}from"./Settings-CzTWvI9I.js";import{t as r}from"./Local-C-xuEKSx.js";import{i}from"./Toast-C-vNzj6O.js";import{t as a}from"./CurrentUser-Bnpgst5a.js";import{t as o}from"./utility-CdukiTyG.js";import{t as s}from"./hotkeys-BaAYi-hq.js";var c=e(t()),l,u=class e{static fromThumbnail(e){let t=e.data(`id`);if(!t)return null;if(this._index.has(t))return new d(this._cache[t]);let n=e[0].dataset,r=n.tags||``,i=r.split(` `),a=[];for(let e of(n.pools+``).split(` `)){let t=parseInt(e);t&&a.push(t)}let o=n.rating||``;if(o!==`s`&&o!==`q`&&o!==`e`)return null;let s={tag_string:r,tags:i,tagcount:i.length,id:t,flags:(n.flags||``).split(` `),rating:o,file_ext:n.fileExt||``,width:parseInt(n.width)||-1,height:parseInt(n.height)||-1,size:parseInt(n.size)||-1,score:parseInt(n.score)||0,fav_count:parseInt(n.favCount)||0,is_favorited:n.isFavorited===`true`,comment_count:parseInt(n.commentCount)||0,uploader:(n.uploader||``).toLowerCase(),uploader_id:parseInt(n.uploaderId)||-1,pools:a,md5:n.md5||``,preview_url:n.previewUrl||``,preview_webp:n.previewWebp||``,sample_url:n.sampleUrl||``,file_url:n.fileUrl||``};return this._cache[t]=s,this._index.add(t),new d(s)}static fromDeferredPosts(e,t,n=!1){if(!e)return null;if(!n&&this._index.has(e))return new d(this._cache[e]);let r=t.tags||``,i=r.split(` `),a=[];for(let e of(t.pools+``).split(` `)){let t=parseInt(e);t&&a.push(t)}let o=t.rating||``;if(o!==`s`&&o!==`q`&&o!==`e`)return null;let s={tag_string:r,tags:i,tagcount:i.length,id:e,flags:(t.flags||``).split(` `),rating:o,file_ext:t.file_ext||``,width:t.width||-1,height:t.height||-1,size:t.size||-1,score:t.score||0,fav_count:t.fav_count||0,is_favorited:!!t.is_favorited,comment_count:t.comment_count||0,uploader:(t.uploader||``).toLowerCase(),uploader_id:t.uploader_id||-1,pools:a,md5:t.md5||``,preview_url:t.preview_url||``,preview_webp:t.preview_webp||``,sample_url:t.sample_url||``,file_url:t.file_url||``};return this._cache[e]=s,this._index.add(e),new d(s)}static register(t){let n=[];for(let r of t){r=(0,c.default)(r),r.removeClass(`blacklistable`);let t=e.fromThumbnail(r);t&&(this._elements[t.id]||(this._elements[t.id]=[]),!this._elements[t.id].some(e=>e.is(r))&&(this._elements[t.id].push(r),this._elementCount++,n.push(r)))}return n}static prune(e){if(Array.isArray(e)){let t=0;for(let n of e)t+=this.prune(n);return t}else if(e.length>1)return this.prune(e.get().map(e=>(0,c.default)(e)));let t=e.data(`id`);if(!t||!this._elements[t]||this._elements[t].length===0)return 0;let n=this._elements[t].length;this._elements[t]=this._elements[t].filter(t=>!t.is(e));let r=n-this._elements[t].length;return this._elementCount-=r,this._elements[t].length===0&&this._pruneElement(t),r}static _pruneElement(e){delete this._elements[e]}static apply(e,t){if(!(!this._elements[e]||this._elements[e].length===0))for(let n of this._elements[e])t(n)}static sample(){let e=[];for(let t of Object.values(this._elements))t.length!=0&&e.push(t[0]);return e}static get(e){return this._index.has(e)?new d(this._cache[e]):null}static getManyByID(e){let t={};for(let n of new Set(e)){let e=this.get(n);e&&(t[n]=e)}return t}static stats(){return{cachedPosts:this._index.size,cachedElements:this._elementCount}}};l=u,l._cache={},l._index=new Set,l._elements={},l._elementCount=0;var d=class{constructor(e){for(let[t,n]of Object.entries(e))this[t]=n}toAttributes(){return{"data-tags":this.tag_string,"data-id":this.id,"data-flags":this.flags.join(` `),"data-rating":this.rating,"data-file-ext":this.file_ext,"data-width":this.width,"data-height":this.height,"data-size":this.size,"data-score":this.score,"data-fav-count":this.fav_count,"data-is-favorited":this.is_favorited,"data-comment-count":this.comment_count,"data-uploader":this.uploader,"data-uploader-id":this.uploader_id,"data-pools":this.pools.join(` `),"data-md5":this.md5,"data-preview-url":this.preview_url,"data-preview-webp":this.preview_webp,"data-sample-url":this.sample_url,"data-file-url":this.file_url}}get ratingLong(){switch(this.rating){case`s`:return`safe`;case`q`:return`questionable`;
1case`e`:return`explicit`;default:return`unknown`}}get isPending(){return this.flags.includes(`pending`)}get isFlagged(){return this.flags.includes(`flagged`)}get isDeleted(){return this.flags.includes(`deleted`)}get isUnavailable(){return!this.preview_url}},f,p=class e{static getFilterType(t){let n=t.split(`:`);if(n.length==1)return`tag`;t=n[0];for(let n of e.FilterTypes)if(t==n)return n;return`tag`}static getComparison(t){if(t.indexOf(`..`)!=-1)return`..`;let n=t.match(/^[<>=]{1,2}/);return n&&e.ComparisonTable[n[0]]||`=`}static normalizeData(t,n){switch(n){case`tag`:return t;case`tagcount`:case`id`:case`width`:case`height`:case`score`:case`favcount`:case`userid`:return parseInt(t);case`rating`:return e.parseRating(t);case`filesize`:return e.parseFilesize(t)}return t}static compare(e,t){switch(t.comparison){case`=`:return e==t.value;case`<`:return e<t.value;case`<=`:return e<=t.value;case`>`:return e>t.value;case`>=`:return e>=t.value;case`..`:return e>=t.value[0]&&e<=t.value[1]}return!1}static tagsMatchesFilter(e,t){return e.tags.indexOf(t)>=0}static wildcardTagMatchesFilter(e,t){for(let n of e.tags)if(t.test(n))return!0;return!1}static parseRating(e){switch(e){case`safe`:case`s`:return`s`;case`questionable`:case`q`:return`q`;case`explicit`:case`e`:return`e`;default:return`x`}}static parseFilesize(e){var t;let n=e.match(/^([0-9]+(?:\.[0-9]+)?)\s*(b|kb|mb)?$/i);if(!n)return NaN;let r=parseFloat(n[1]);switch((t=n[2])==null?void 0:t.toLowerCase()){case`b`:return Math.floor(r);case`kb`:return Math.floor(r*1024);case`mb`:return Math.floor(r*1048576);default:return Math.floor(r)}}};f=p,f.FilterTests={tag:(e,t)=>f.tagsMatchesFilter(t,e.value),tagcount:(e,t)=>f.compare(t.tagcount,e),id:(e,t)=>f.compare(t.id,e),status:(e,t)=>t.flags.indexOf(e.value)>=0,rating:(e,t)=>t.rating===e.value,type:(e,t)=>t.file_ext===e.value,width:(e,t)=>f.compare(t.width,e),height:(e,t)=>f.compare(t.height,e),filesize:(e,t)=>f.compare(t.size,e),score:(e,t)=>f.compare(t.score,e),favcount:(e,t)=>f.compare(t.fav_count,e),fav:(e,t)=>t.is_favorited,uploader:(e,t)=>f.FilterTests.user(e,t),user:(e,t)=>e.value.startsWith(`!`)?t.uploader_id===parseInt(e.value.slice(1)):t.uploader===e.value,userid:(e,t)=>f.compare(t.uploader_id,e),username:(e,t)=>t.uploader===e.value,pool:(e,t)=>t.pools.includes(parseInt(e.value)||0),wildcard:(e,t)=>f.wildcardTagMatchesFilter(t,e.value)},f.FilterTypes=Object.keys(f.FilterTests),f.ComparisonTable={"<=":`<=`,">=":`>=`,"=<":`<=`,"=>":`>=`,"<":`<`,">":`>`};var m=class{constructor(e){e=e.trim().toLowerCase();let t=e.match(/^(~|-)+/);if(t){let n=t[0];this.optional=n.includes(`~`),this.inverted=n.includes(`-`),e=e.slice(n.length)}else this.optional=!1,this.inverted=!1;if(this.type=p.getFilterType(e),this.type!==`tag`)e=e.slice(this.type.length+1);else if(e.includes(`*`)){this.value=RegExp(`^${o.regexp_escape(e).replace(/\\\*/g,`.*`)}$`),this.type=`wildcard`;return}if(this.comparison=p.getComparison(e),this.comparison!=`=`&&this.comparison!=`..`&&(e=e.slice(this.comparison.length)),this.comparison==`..`)if(e.startsWith(`..`))this.comparison=`<=`,this.value=p.normalizeData(e.slice(2),this.type);else if(e.endsWith(`..`))this.comparison=`>=`,this.value=p.normalizeData(e.slice(0,-2),this.type);else{let t=e.split(`..`);t.length==2?this.value=[p.normalizeData(t[0],this.type),p.normalizeData(t[1],this.type)]:(this.comparison=`=`,this.value=NaN)}else this.value=p.normalizeData(e,this.type),this.comparison===`=`&&this.type===`filesize`&&(this.comparison=`..`,this.value=[Math.trunc(this.value*.95),Math.trunc(this.value*1.05)])}test(e){let t=p.FilterTests[this.type](this,e);return this.inverted?!t:t}},h=class e{static create(t){return t=t.trim(),!t||t.startsWith(`#`)?null:(t=t.toLowerCase().replace(/ #.*$/,``),new e(t))}constructor(e){this.text=e,this._enabled=!r.Blacklist.FilterState.has(e),this.matchIDs=new Set,this.tokens=[],this.optional=[];for(let e of new Set(this.text.split(` `).filter(e=>e.trim()!==``))){let t=new m(e);t.optional?this.optional.push(t):this.tokens.push(t)}}get enabled(){return this._enabled}set enabled(e){this._enabled=e==1,this._enabled?r.Blacklist.FilterState.delete(this.text):r.Blacklist.FilterState.add(this.text),x.updatePostVisibility()}setEnabledWithoutSaving(e){this._enabled=e==1}updateWithElements(e){if(Array.isArray(e)){if(e.length==0)return!1;let t=!1;for(let n of e)this.updateWithElements((0,c.default)(n))&&(t=!0);return t}else if(e.length>1)return this.updateWithElements(e.get().map(e=>(0,c.default)(e)));let t=u.fromThumbnail(e);return t?this.updateWithPosts(t):!1}updateWithPosts(e){if(Array.isArray(e)){if(e.length==0)return!1;let t=!1;for(let n of e)this.updateWithPosts(n)&&(t=!0);return t}if(this.matchIDs.has(e.id))return!0;let t=e,n=!0;if(this.tokens.length){for(let e of this.tokens)if(n=e.test(t),!n)break}if(n&&this.optional.length){let e=!1;for(let n of this.optional)if(e=n.test(t),e)break;e||(n=!1)}return n===!0?this.matchIDs.add(t.id):n===!1&&this.matchIDs.delete(t.id),n===!0}},g,_=class e{static initializeAll(){document.querySelectorAll(`section.blackl
1ist-ui.staged`).forEach(t=>{this.registry.push(new e(t))}),(0,c.default)(document).off(`e621:blacklist:state-changed.blacklistWidget`).on(`e621:blacklist:state-changed.blacklistWidget`,()=>{for(let e of this.registry)e.rebuildFilters()}),e.isHotkeyRegistered||(e.isHotkeyRegistered=!0,s.register(`blacklist`,()=>{this.registry.length&&this.registry[0].toggleAllFilters()}))}constructor(e){this.$wrapper=(0,c.default)(e).removeClass(`staged`),this.$counter=this.$wrapper.find(`span.blacklisted-count`),this.post=parseInt(this.$wrapper.attr(`post`)||``),this.hasPost=!Number.isNaN(this.post),this.$wrapper.attr(`collapsed`,r.Blacklist.Collapsed+``).find(`.blacklist-header`).off(`click.blacklistWidget`).on(`click.blacklistWidget`,()=>{let e=this.$wrapper.attr(`collapsed`)!==`true`;this.$wrapper.attr(`collapsed`,e+``),r.Blacklist.Collapsed=e}),this.$toggle=this.$wrapper.find(`button.blacklist-toggle-all`),this.$toggle.text(`Disable All Filters`).off(`click.blacklistWidget`).on(`click.blacklistWidget`,()=>{if(this.$toggle.attr(`is-enabling`)==`true`){for(let e of Object.values(x.filters))e.setEnabledWithoutSaving(!0);r.Blacklist.FilterState.clear()}else{let e=new Set;for(let t of Object.values(x.filters))t.setEnabledWithoutSaving(!1),e.add(t.text);r.Blacklist.FilterState=e}(0,c.default)(document).trigger(`e621:blacklist:state-changed`),x.updatePostVisibility()}),this.$container=this.$wrapper.find(`.blacklist-filters`),this.rebuildFilters()}toggleAllFilters(){this.$toggle.length&&this.$toggle[0].click()}rebuildFilters(){this.$container.html(``);let e=0,t=0;for(let[n,r]of Object.entries(x.filters)){if(r.matchIDs.size==0||this.hasPost&&!r.matchIDs.has(this.post))continue;e++,r.enabled||t++;let i=(0,c.default)(`<li>`).attr(`enabled`,r.enabled+``).on(`click`,()=>{r.enabled=!r.enabled}).appendTo(this.$container),a=(0,c.default)(`<a>`).attr(`href`,`/posts?tags=`+encodeURIComponent(n)).text(n.replace(/_/g,`​_`).replace(/ -/g,` ‑`)).on(`click`,e=>{e.preventDefault()}).appendTo(i);(0,c.default)(`<span>`).text(r.matchIDs.size).appendTo(a)}this.$wrapper.attr(`filters`,e),this.$counter.text(`(`+x.hiddenPosts.size+`)`);let n=t?`Enable All Filters`:`Disable All Filters`;this.$toggle.text(n).attr({"is-enabling":t>0,"aria-label":n})}};g=_,g.isHotkeyRegistered=!1,g.registry=[];var v=class e{static initializeAll(){if(a.settings.blacklistUsers)for(let t of Object.values(x.filters)){if(!t.tokens.length)continue;let n=t.tokens[0];switch(n.type){case`user`:if(n.value.startsWith(`!`)){e.hideComment(`creator-id`,n.value.slice(1));continue}case`username`:e.hideComment(`creator`,n.value);continue;case`userid`:e.hideComment(`creator-id`,n.value);continue}}}static hideComment(e,t){t=CSS.escape(t),(0,c.default)(`article[data-${e}="${t}"]`).hide()}},y,b=class e{static get instance(){return this._instance||(this._instance=new e),this._instance}constructor(){if(this.isPostsShow=!1,this.filters={},this.hiddenPosts=new Set,this.matchedPosts=new Set,e._instance)throw Error(`BlacklistManager is a singleton class. Use BlacklistManager.instance to access the instance.`);this.regenerateFilters(),(0,c.default)(()=>this.onDOMLoad()),document.addEventListener(`e621:blacklistUpdated`,()=>{this.regenerateFilters(),this.addPosts(u.sample()),this.recalculateMatchedPosts(),this.updatePostVisibility(),this.updateThumbnailStyles()})}onDOMLoad(){if(this.isPostsShow=(0,c.default)(`#image-container`).length>0,this.addPosts((0,c.default)(`.blacklistable`)),this.recalculateMatchedPosts(),this.updateThumbnailStyles(),this.updatePostVisibility(),(0,c.default)(`#blacklisted-hider`).remove(),_.initializeAll(),v.initializeAll(),!this.isPostsShow)return;let e=(0,c.default)(`#image-container[data-file-ext='mp4'],                       #image-container[data-file-ext='webm']`).on(`blk:hide`,()=>{let t=e.find(`video`);t.length&&t[0].pause()})}updatePostVisibility(){let e=this.hiddenPosts,t=[];for(let e of Object.values(this.filters))e.enabled&&(t=t.concat(Array.from(e.matchIDs)));this.hiddenPosts=new Set(t.filter(e=>e));let n=[...this.hiddenPosts].filter(t=>!e.has(t)),r=[...e].filter(e=>!this.hiddenPosts.has(e));(0,c.default)(document).trigger(`e621:blacklist:state-changed`);for(let e of n)u.apply(e,e=>{e.addClass(`blacklisted`).trigger(`blk:hide`)});for(let e of r)u.apply(e,e=>{e.removeClass(`blacklisted`).trigger(`blk:show`)});this.isPostsShow&&((0,c.default)(`#image-container`).hasClass(`blacklisted`)?(0,c.default)(`#note-container`).css(`visibility`,`hidden`):(0,c.default)(`#note-container`).css(`visibility`,`visible`))}
1addPosts(e){let t=u.register(e);for(let t of Object.values(this.filters))t.updateWithElements(e);for(let e of t){let t=e.data(`id`);this.hiddenPosts.has(t)&&e.addClass(`blacklisted`).trigger(`blk:hide`)}}loadDeferredPosts(e){for(let t of Object.values(this.filters))t.updateWithPosts(e)}recalculateMatchedPosts(){let e=[];for(let t of Object.values(this.filters))e=e.concat(Array.from(t.matchIDs));this.matchedPosts=new Set(e)}updateThumbnailStyles(){(0,c.default)(`.filter-matches`).removeClass(`filter-matches`);for(let e of this.matchedPosts)u.apply(e,e=>{e.addClass(`filter-matches`)})}regenerateFilters(){this.filters={};for(let e of a.blacklist){let t=h.create(e);t&&(this.filters[t.text]=t)}let e=Object.keys(this.filters);for(let t of r.Blacklist.FilterState)e.includes(t)||r.Blacklist.FilterState.delete(t)}};y=b,y._instance=null;var x=b.instance,S,C=class{static get renderedCount(){return this._counter}static render(e,t={}){if(!e)return null;let{showStatistics:n=!0,showTypeBadges:r=!0,inline:i=!1,native:o=!1,classes:s,jpegUrl:l,webpUrl:d}=t,f=(0,c.default)(`<article>`).addClass(`thumbnail rating-`+e.ratingLong).attr(e.toAttributes());(e.isDeleted||e.isUnavailable)&&f.addClass(`deleted`),x.hiddenPosts.has(e.id)&&f.addClass(`blacklisted`),x.matchedPosts.has(e.id)&&f.addClass(`filter-matches`),n||f.addClass(`no-stats`),r||f.addClass(`no-type-badges`),i&&f.addClass(`inline`),o&&f.addClass(`native`),s&&f.addClass(s),e.isUnavailable||(l&&(e.preview_url?e.preview_url=e.preview_url.replace(/\/data\/.*$/,l):e.preview_url=l),d&&(e.preview_webp?e.preview_webp=e.preview_webp.replace(/\/data\/.*$/,d):e.preview_webp=d));let p=(0,c.default)(`<a>`).addClass(`thm-link`).attr({href:`/posts/${e.id}`,"data-target":e.id,"data-file-ext":e.file_ext}).appendTo(f);if(!e.isUnavailable&&(!e.isDeleted||a.is.staff)&&p.append(this.renderPicture(e)),n){let t=(0,c.default)(`<div>`).addClass(`thm-desc thm-rating-${e.rating}`).appendTo(f);(0,c.default)(`<span class='thm-desc-a'>`).appendTo(t).append(this.renderScore(e.score)).append(this.renderFavorites(e.fav_count)).append(this.renderComments(e.comment_count)),this.renderRating(e.rating).appendTo(t)}return this._counter++,u.register(f),f}static renderPlaceholder(){return(0,c.default)(`<article>`).addClass(`thumbnail placeholder`)}static renderPicture(e){let t=(0,c.default)(`<picture>`),r=e.preview_url||`/images/deleted-preview.png`;return n.Posts.webp_enabled&&e.preview_webp&&(0,c.default)(`<source>`).attr({srcset:e.preview_webp,type:`image/webp`}).appendTo(t),(0,c.default)(`<img>`).attr({src:r,alt:`post #${e.id}`,loading:`lazy`}).appendTo(t),t}static renderScore(e){let t=e>0?`arrow_up_dash`:e<0?`arrow_down_dash`:`score`;return(0,c.default)(`<span>`).addClass(`thm-desc-m thm-score`).addClass(e>0?`thm-score-positive`:e<0?`thm-score-negative`:`thm-score-neutral`).append(i.render(t)).append(String(Math.abs(e)))}static renderFavorites(e){return(0,c.default)(`<span>`).addClass(`thm-desc-m thm-favorites`).append(i.render(`favorites`)).append(String(e))}static renderComments(e){return(0,c.default)(`<span>`).addClass(`thm-desc-m thm-comments`).append(i.render(`comments`)).append(String(e))}static renderRating(e){return(0,c.default)(`<span>`).addClass(`thm-desc-b thm-rating`).text((e||`?`).toUpperCase())}};S=C,S._counter=0;export{x as n,u as r,C as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.