-
Notifications
You must be signed in to change notification settings - Fork 9
/
bookmarklet
1 lines (1 loc) · 3.42 KB
/
bookmarklet
1
javascript:(function()%7B(async()%3D%3E%7Blet%20t%3Ddocument.createElement(%22dialog%22)%2Cn%3Ddocument.createElement(%22label%22)%2Cl%3Ddocument.createElement(%22progress%22)%3Bt.style.cssText%3D%22display%3A%20flex%3B%20flex-direction%3A%20column%3B%20gap%3A%2015px%3B%20padding%3A%2020px%3B%22%2Ct.appendChild(n)%2Ct.appendChild(l)%2Cdocument.querySelector(%22ytd-app%22).appendChild(t)%2Ct.showModal()%2Cn.innerText%3D%22Loading%20subscriptions...%22%3Blet%20o%3Ddocument.getElementById(%22content%22)%2Cr%3Bdo%20r%3Do.offsetHeight%2Cwindow.scrollBy(0%2C1e5)%2Cawait%20new%20Promise(t%3D%3EsetTimeout(t%2C500))%3Bwhile(null!%3Do.querySelector(%22%23spinnerContainer.active%22)%7C%7Co.offsetHeight%3Er)%3Btry%7Blet%20a%3D%5B...o.querySelectorAll(%22ytd-browse%3Anot(%5Bhidden%5D)%20%23main-link.channel-link%22)%5D%3Bl.max%3Da.length%2Cl.value%3D0%3Blet%20i%3D%5B%5D%2Cc%3Dwindow.chrome%3FtrustedTypes.createPolicy(%22m%22%2C%7BcreateHTML%3At%3D%3Et%7D)%3Anull%3Bfor(e%20of%20a)%7Bn.innerText%3D%60Fetching%20URLS...%20(%24%7Bl.value%7D%2F%24%7Bl.max%7D)%60%3Btry%7Blet%20s%3De.querySelector(%22yt-formatted-string.ytd-channel-name%22).innerText%2Cd%3Dawait%20fetch(e.href)%3Bif(!d.ok)%7Bconsole.error(%60Couldn't%20fetch%20channel%20page%20for%20%24%7Bs%7D%60)%3Bcontinue%7Dlet%20u%3Dawait%20d.text()%3Bwindow.chrome%26%26(u%3Dc.createHTML(u))%3Blet%20h%3DDocument.parseHTMLUnsafe(u)%2Cp%3Dh.querySelectorAll(%22body%20%3E%20link%5Brel%3Dalternate%5D%2C%20body%20%3E%20link%5Brel%3Dcanonical%5D%22)%2Cm%3D%5B...p%5D.map(t%3D%3Et.href.match(%22%2Fchannel%2F(%5Ba-zA-Z0-9_-%5D%2B%3F)%24%22)).find(t%3D%3Enull!%3Dt)%3Bif(null%3D%3Dm)%7Bconsole.error(%60Couldn't%20find%20channel%20id%20for%20%24%7Bs%7D%60)%3Bcontinue%7Di.push(%5B%60https%3A%2F%2Fwww.youtube.com%2Ffeeds%2Fvideos.xml%3Fchannel_id%3D%24%7Bm%5B1%5D%7D%60%2Cs%2Ce.href%5D)%7Dfinally%7Bl.value%2B%2B%2Cl.replaceWith(l)%7D%7D0%3D%3Da.length%26%26alert(%22Couldn't%20find%20any%20subscriptions%22)%3Blet%20f%3Da.length-i.length%3Bf%3E0%26%26alert(%60%24%7Bf%7D%20channel%24%7Bf%3E1%3F%22s%22%3A%22%22%7D%20couldn't%20be%20fetched.%20Check%20the%20console%20for%20more%20info.%60)%3Blet%20y%3Dt%3D%3Et.replace(%2F%5B%3C%3E%26'%22%5D%2Fg%2Ct%3D%3E(%7B%22%3C%22%3A%22%26lt%3B%22%2C%22%3E%22%3A%22%26gt%3B%22%2C%22%26%22%3A%22%26amp%3B%22%2C%22'%22%3A%22%26apos%3B%22%2C'%22'%3A%22%26quot%3B%22%7D)%5Bt%5D)%3Bif(i.length%3E0)%7Bconsole.log(i.map((%5Bt%5D)%3D%3Et).join(%22%5Cn%22))%3Blet%20g%3D%60%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3Copml%20version%3D%221.0%22%3E%0A%09%3Chead%3E%0A%09%09%3Ctitle%3EYouTube%20Subscriptions%20as%20RSS%3C%2Ftitle%3E%0A%09%3C%2Fhead%3E%0A%09%3Cbody%3E%0A%09%09%3Coutline%20text%3D%22YouTube%20Subscriptions%22%3E%24%7Bi.map((%5Bt%2Cn%2Cl%5D)%3D%3E%60%0A%09%09%09%3Coutline%20type%3D%22rss%22%20text%3D%22%24%7By(n)%7D%22%20title%3D%22%24%7By(n)%7D%22%20xmlUrl%3D%22%24%7Bt%7D%22%20htmlUrl%3D%22%24%7Bl%7D%22%2F%3E%60).join(%22%22)%7D%0A%09%09%3C%2Foutline%3E%0A%09%3C%2Fbody%3E%0A%3C%2Fopml%3E%60%2Cb%3Dwindow.URL.createObjectURL(new%20Blob(%5Bg%5D%2C%7Btype%3A%22text%2Fplain%22%7D))%2Cx%3Ddocument.createElement(%22a%22)%3Bx.setAttribute(%22download%22%2C%22youtube_subs.opml%22)%2Cx.setAttribute(%22href%22%2Cb)%2Cx.dataset.downloadurl%3D%60text%2Fplain%3Ayoutube_subs.opml%3A%24%7Bb%7D%60%2Cx.click()%7D%7Dcatch(%24)%7Bconsole.error(%24)%2Calert(%22Something%20went%20wrong.%20Check%20the%20console%20for%20more%20info.%22)%7Dfinally%7Bt.close()%2Ct.remove()%7D%7D)()%3B%7D)()%3B