PageSourceSearch

https://www.tirolo.com/_assets/1798f66a72c0609b2ee5b404d10475ff/Di…/Assistants/Bookmarks.js?1790252148

js tirolo.com collected 2026-09-24 23:16:06 UTC 6,600 bytes, 1 lines download raw bytes

1(()=>{"use strict";class t{constructor(){this.collectionId="",this.objectIdents=[],this.listeners=[],window.addEventListener("storage",function(t,e=100,o={}){if("function"!=typeof t)throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");if("boolean"==typeof o)throw new TypeError("The `options` parameter must be an object, not a boolean. Use `{immediate: true}` instead.");const{immediate:s}=o;let a,i,n,r,d;function c(){const e=a,o=i;return a=void 0,i=void 0,d=t.apply(e,o),d}function l(){const t=Date.now()-r;t<e&&t>=0?n=setTimeout(l,e-t):(n=void 0,s||(d=c()))}const h=function(...t){if(a&&this!==a&&Object.getPrototypeOf(this)===Object.getPrototypeOf(a))throw new Error("Debounced method called with different contexts of the same prototype.");a=this,i=t,r=Date.now();const o=s&&!n;if(n||(n=setTimeout(l,e)),o)return d=c(),d};return Object.defineProperty(h,"isPending",{get:()=>void 0!==n}),h.clear=()=>{n&&(clearTimeout(n),n=void 0,a=void 0,i=void 0)},h.flush=()=>{n&&h.trigger()},h.trigger=()=>{d=c(),h.clear()},h}((()=>this._read()),250)),this._read()}static available(){const t=window.localStorage,e="__storage_test__";try{return t.setItem(e,e),t.removeItem(e),!0}catch(e){return e instanceof DOMException&&(22===e.code||1014===e.code||"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&0!==t.length}}add(t){return-1===this.objectIdents.indexOf(t)?this._request({method:"PUT",body:JSON.stringify({identsToAdd:[t]})}):Promise.reject("already stored")}remove(t){return this.objectIdents.indexOf(t)>-1?this._request({method:"PUT",body:JSON.stringify({identsToRemove:[t]})}):Promise.reject("not stored")}get(){return this.objectIdents}clear(){return this._request({method:"DELETE"})}listen(t){t(this.objectIdents),this.listeners.push(t)}_read(){let t;try{t=JSON.parse(localStorage.getItem("bookmarks")||"{}")}catch(e){localStorage.removeItem("bookmarks"),t={}}this.collectionId=t.collectionId||"",this.objectIdents=t.objectIdents||[],this.listeners.forEach((t=>t(this.objectIdents)))}async _request(t){const e=Date.now();let o;try{o=JSON.parse(localStorage.getItem("bookmarks_updating")||"null")}catch(t){localStorage.removeItem("bookmarks_updating"),o=null}return"number"==typeof o&&e-o<=1e4?Promise.reject("already updating"):(localStorage.setItem("bookmarks_updating",JSON.stringify(e)),this.collectionId||(this.collectionId=await this._create()),fetch(`/action/bookmarks?collectionId=${this.collectionId}&t=${Date.now()}`,{...t,headers:{"Content-Type":"application/json"}}).then((t=>t.json())).then((t=>{this.collectionId=t.id||"",this.objectIdents=t.idents||[],localStorage.setItem("bookmarks",JSON.stringify({collectionId:this.collectionId,objectIdents:this.objectIdents})),this.listeners.forEach((t=>t(this.objectIdents))),localStorage.removeItem("bookmarks_updating")})).catch((t=>{throw localStorage.removeItem("bookmarks_updating"),t})))}_create(){return fetch("/action/bookmarks",{method:"POST",headers:{"Content-Type":"application/json"}}).then((t=>t.json())).then((t=>t.id))}}class e{constructor(t){this.parent=document.documentElement||document.body.parentNode,this.buttons=[...document.querySelectorAll("[data-bookmarked][data-ident]")],this.links=document.querySelectorAll("#pageHeader .bookmarks"),this.counters=document.querySelectorAll("[data-bookmarks-counter]"),this.deletors=document.querySelectorAll("[data-bookmarks-delete]"),this.page=document.querySelector("[data-bookmarks-collection-id]"),this.storage=t,this.storage.listen((t=>this._update(t))),this.hiddenUpdates=0}activate(){const t=this.storage.get();if(this.parent.classList.add("bookmarks-active"),this.page){const e=this.page.dataset.bookmarksCollectionId,o=this.page.querySelector("[data-bookmarks-text-empty]"),s=this.page.querySelector("[data-bookmarks-text-filled]"),a=this.page.querySelector("[data-bookmarks-text-shared]");e===this.storage.collectionId&&t.length>0?(o.style.display="none",s.style.display="block",a.style.display="none"):e&&e!==this.storage.collectionId?(o.style.display="none",s.style.display="none",a.style.display="block"):(o.style.display="block",s.style.display="none",a.style.display="none"),e===this.storage.collectionId&&t.length>0&&this.buttons.forEach((t=>
1t.remove())),this.deletors.forEach((t=>{e&&e!==this.storage.collectionId?t.remove():t.addEventListener("click",(()=>{this.storage.remove(t.dataset.bookmarksDelete).then((()=>window.location.reload()))}))})),document.addEventListener("visibilitychange",(()=>{this.list&&document.visibilityState&&this.hiddenUpdates>0&&window.location.reload()}))}this._update(this.storage.get()),this._addBookmarkButtonEvents()}reconstruct(){const t=[...this.buttons,...document.querySelectorAll("[data-bookmarked][data-ident]:not([data-init])")];this.buttons=t.filter((t=>document.body.contains(t))),this._update(this.storage.get()),this._addBookmarkButtonEvents()}_addBookmarkButtonEvents(){this.buttons.filter((t=>!t.dataset.init)).forEach((t=>{t.setAttribute("data-init","1"),t.addEventListener("click",(()=>this._handleBookmarkButtonClick(t)))}))}_handleBookmarkButtonClick(t){const e=t.dataset.ident;this._handleButtonAvailablity(!1),t.classList.add("loading"),"1"===t.dataset.bookmarked?this.storage.remove(e).then((()=>{t.dataset.bookmarked="0",t.classList.remove("loading"),this._handleButtonAvailablity(!0),this.list&&this.list.dataset.bookmarksPublicKey===this.storage.publicKey&&t.closest("[data-bookmarks-ident="+e+"]")?.remove()})).catch((e=>{console.warn(e),t.classList.remove("loading"),this._handleButtonAvailablity(!0)})):this.storage.add(e).then((()=>{t.dataset.bookmarked="1",t.classList.remove("loading"),this._handleButtonAvailablity(!0)})).catch((e=>{console.warn(e),t.classList.remove("loading"),this._handleButtonAvailablity(!0)}))}_handleButtonAvailablity(t){this.buttons.forEach((e=>{e.disabled=!t}))}_update(t){const e=this.storage.collectionId;e&&this.links.forEach((t=>{const o=new URL(t.href);o.searchParams.set("collectionId",e),t.href=o.href})),this.counters.forEach((e=>{e.dataset.bookmarksCounter=t.length,e.innerText=t.length})),this.buttons.forEach((e=>{t.indexOf(e.dataset.ident)>-1?e.dataset.bookmarked="1":e.dataset.bookmarked="0"})),document.hidden?this.hiddenUpdates++:this.hiddenUpdates=0}}if(t.available()){const o=new e(new t);o.activate(),document.addEventListener("ContentLoader.load",(()=>o.reconstruct())),document.addEventListener("infiniteScrolling.showPrevious",(()=>
1o.reconstruct())),document.addEventListener("infiniteScrolling.showFollowing",(()=>o.reconstruct()))}})();

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.