forked from MarshaIIs/ChromeWebStoreSorter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookmarklet.js
1 lines (1 loc) · 5.53 KB
/
bookmarklet.js
1
javascript:(function()%7Basync function main()%7Bconsole.clear()%3Btry%7Bawait validateUrl()%3Bvar e%3Dconfirm("Start sorting%3F")%3Bconsole.clear()%7Dcatch(e)%7Breturn%7De%26%26(blurPage(!0)%2CsortWebstore())%7Dasync function stop(e)%7Bstop%3D!0%2CblurPage(!1)%2Cwindow.scrollTo(0%2C0)%2C"auto"%3D%3D%3D!e%26%26console.info("%25cThe script was force stopped%5Cn%25cDid something go wrong%3F %3A("%2C"color%3A orange%3B font-weight%3A bold%3B font-size%3A 130%25%3B"%2C"")%7Dasync function blurPage(e)%7Blet o%3D"html %7B filter%3A blur(5px)%3B %7D"%3Bif(e)%7Blet e%3Ddocument.createElement("style")%3Be.textContent%3Do%2Cdocument.head.appendChild(e)%7Delse document.head.querySelectorAll("style").forEach((e%3D>%7Be.textContent.includes(o)%26%26e.remove()%7D))%7Dasync function validateUrl()%7Bconst e%3D"chrome.google.com"%2Co%3D"webstore%2Fsearch"%2Ct%3D"extensions"%2Cn%3Dwindow.location.hostname.toLowerCase()%2Cr%3Dwindow.location.pathname.toLowerCase()%2C%5Bl%2Ci%2Cs%5D%3Dr.split("%2F").slice(1)%2Ca%3D%60%24%7Bl%7D%2F%24%7Bi%7D%60%2Cc%3Dwindow.location.search.toLowerCase()%2Cg%3Dnew URLSearchParams(c)%2Cd%3Dg.get("_category")%3F%3F""%2Ch%3Dg.get("hl")%3F%3F""%3Bif(n!%3D%3De)throw console.error(%60%25cError not in Chrome Web Store!%5Cn%25cSite should be "%24%7Be%7D"%60%2C"color%3Aorange%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%3Bif(a!%3D%3Do)throw console.error(%60%25cError not searching Chrome Web Store!%5Cn%25cPath should be "%2F%24%7Bo%7D%2F..."%60%2C"color%3Aorange%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%3Bif(c!%3D%3D%60%3F_category%3D%24%7Bt%7D%60%26%26c!%3D%3D%60%3Fhl%3D%24%7Bh%7D%26_category%3D%24%7Bt%7D%60)%7Bif(console.warn(%60%25cError search not filtered to "%24%7Bt%7D" !%5Cn%25cRecommend searching for "%24%7Bt%7D".%60%2C"color%3Aorange%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%2Cconfirm(%60ERROR!%5Cn%24%7Bt%3D%3D%3Dd%3F"Search seems broken."%3A%60Recommend searching for %24%7Bt%7D.%60%7D%5CnWant to search in %24%7Bt%7D%3F%60))%7Bconsole.clear()%2Cconsole.info("%25cAttempting to fix search...%25c%5CnRemember to %25crestart Sorting%25c after the page loads"%2C"color%3Aorange%3B font-size%3A 130%25%3B font-weight%3A bold"%2C""%2C"font-weight%3A bold%3B color%3A skyblue%3B border-bottom%3A solid skyblue 2px"%2C"")%2Cawait new Promise((e%3D>setTimeout(e%2C2500)))%3Bconst e%3D%60https%3A%2F%2F%24%7Bn%7D%24%7Br%7D%3F_category%3D%24%7Bt%7D%60%3Btry%7Bconsole.info("%25cSuccess!%5Cn%25cTaking you to search for extensions now."%2C"color%3Alimegreen%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%2Cawait new Promise((e%3D>setTimeout(e%2C1500)))%2Cwindow.location.assign(e)%7Dcatch(e)%7Bthrow console.clear()%2Cconsole.error("%25cFatal error!%5Cn%25cSorry search fix failed.%5Cn"%2C"color%3Aorange%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%2Ce%7D%7Delse console.info("%25cContinuing sort!%5Cn%25cSearching without filtering for extensions."%2C"color%3Aorange%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%7Delse console.info("%25cSuccess!%5Cn%25cURL is valid."%2C"color%3Alimegreen%3B font-size%3A 130%25%3B font-weight%3A bold"%2C"")%3Breturn new Promise((e%3D>%7BsetTimeout((()%3D>%7Be("success")%7D)%2C800)%7D))%7Dfunction sortWebstore(e%3D2)%7Bconsole.info("%25cSorting search results!%5Cn%25cThis might take a moment. Be right back."%2C"font-size%3A 130%25%3B font-weight%3A bold%3B color%3A skyblue%3B"%2C"")%3Blet o%2Ct%3D0%2Cn%3D0%2Cr%3D0%2Cl%3D!1%3B!function e(r)%7Bt%2B%2B%2Cdocument.querySelectorAll("div.h-a-Hd-mb.a-Hd-mb")%5B0%5D.scrollIntoView()%3Blet i%3Ddocument.querySelectorAll(".a-d-na.a-d.webstore-test-wall-tile.a-d-zc.Xd.dd")%3Bo%3Di.length%2Cn!%3Do%26%26(n%3Do)%3Bif(t>r%7C%7Cl)return t%3D0%2Cn%3D0%2Cl%3D!1%2Ci%5Bo-1%5D.scrollIntoView(!1)%2Cvoid function()%7Blet e%3Ddocument.querySelectorAll(".a-d-na.a-d.webstore-test-wall-tile.a-d-zc.Xd.dd")%2Co%3DArray.from(e)%2Ct%3D%5B%7B%7D%5D%3Btry%7Bo.forEach((e%3D>%7BitemTitle%3De.querySelector("div.a-na-d-w").textContent.toString()%2CorderingNum%3De.attributes.hasOwnProperty("index")%3FNumber(e.attributes.index.value.toString().replace(%2F%2C%2Fg%2C""))%3A0%2Crating_str%3De.getElementsByClassName("nAtiRe").length>0%3FNumber(e.getElementsByClassName("nAtiRe")%5B0%5D.textContent.toString().replace(%2F%2C%2Fg%2C"")).toString()%3A"Not voted"%2Ct.push(%7BOrder%3AorderingNum%2CTitle%3AitemTitle%2CRating%3Arating_str%7D)%7D))%7Dcatch(e)%7Bthrow console.error(e)%7Do.sort(((e%2Co)%3D>%7Blet t%3De.getElementsByClassName("nAtiRe").length>0%3FNumber(e.getElementsByClassName("nAtiRe")%5B0%5D.textContent.toString().replace(%2F%2C%2Fg%2C""))%3A0%3Breturn(o.getElementsByClassName("nAtiRe").length>0%3FNumber(o.getElementsByClassName("nAtiRe")%5B0%5D.textContent.toString().replace(%2F%2C%2Fg%2C""))%3A0)-t%7D))%3Blet n%3Ddocument.querySelectorAll('.h-a-x > %5Brole%3D"grid"%5D > %5Brole%3D"row"%5D')%2Cr%3DArray.from(n)%3Bfor(let e%3D0%3Be<r.length%3Be%2B%2B)%7Brow_start%3D3*e%3Bfor(let t%3Drow_start%3Bt<row_start%2B3%26%26t<o.length%3Bt%2B%2B)r%5Be%5D.appendChild(o%5Bt%5D)%7Dconsole.info("%25cSorting finished!!%5Cn%25cResults are now ranked by the number of ratings they have!"%2C"color%3A limegreen%3B font-weight%3A bold%3B font-size%3A 130%25%3B"%2C"")%2Cconsole.groupCollapsed("Sorted data info")%2Cconsole.table(t.slice(1)%2C%5B"Title"%2C"Rating"%2C"Order"%5D)%2Cconsole.groupEnd()%2Cstop("auto")%7D()%3BsetTimeout((()%3D>%7Be(r)%7D)%2C500)%7D(100)%2Cfunction o()%7B"display%3A none%3B"%3D%3D%3Ddocument.querySelectorAll("div.h-a-Kd.a-Hd-mb")%5B0%5D.attributes.style.value%3Fr%2B%2B%3Ar%3D0%3Bif(r>e)return r%3D0%2Cvoid(l%3D!0)%3BsetTimeout((()%3D>%7Bo()%7D)%2C500)%7D()%7Dmain()%3B%7D)()