rdx icon indicating copy to clipboard operation
rdx copied to clipboard

The javaScript does not work to download subscriptions

Open dnet890 opened this issue 1 year ago • 14 comments

Hi I tried to copy paste this command javascript:(function(){const subnames=document.querySelector('.subscription-box a').href.split('/r/')[1].split('+');const jsonData=JSON.stringify(subnames,null,2);const blob=new Blob([jsonData],{type:'application/json'});const downloadLink=Object.assign(document.createElement('a'),{href:URL.createObjectURL(blob),download:'rdx_subs.json'});document.body.appendChild(downloadLink).click()&&document.body.removeChild(downloadLink);})();

to download json file. But, it is working when I logged out and when I try to logged in. it shows nothing. What do you think?

dnet890 avatar Feb 01 '24 08:02 dnet890

  1. Are you sure you are using old reddit? this url - https://old.reddit.com/subreddits
  2. Are you copy pasting the code? if so some browsers like chrome remove the javascript: part when you paste it in the url bar.
  3. What device and browser are you using, if possible provide the screenshot of your subreddits page.
  4. No rdx_subs.json is file is downloading right? Is it showing any error, maybe check the console of your browser if it is desktop.

I just copy pasted the code and it worked on my end (i'am logged in to reddit) so I will need a little more info.

avadhesh18 avatar Feb 01 '24 12:02 avadhesh18

Hi Thanks for your reply and here are my answers:

  1. I use Chromium deb on Ubuntu
  2. Here are the screenshots and videos and Sorry if there is one video that quite messed up because there is my account on that old reddit and I want to protect my privacy

https://github.com/avadhesh18/rdx/assets/29157187/5d5e0572-2e5d-4811-8079-03eec729c4d5

2024-02-01_21-36_1 2024-02-01_21-36

https://github.com/avadhesh18/rdx/assets/29157187/af17c83c-39bc-47ad-a605-455dcf036b92

https://github.com/avadhesh18/rdx/assets/29157187/ea048a4b-56b5-4a40-9ad8-c66d3229133a

2024-02-01_21-36_1

https://github.com/avadhesh18/rdx/assets/29157187/e227b610-ff7b-4d70-857d-173e757502ba

2024-02-01_21-36

dnet890 avatar Feb 01 '24 13:02 dnet890

Sorry to add something. I tested it on Google chrome on Windows 10 and I got same problem like that

dnet890 avatar Feb 01 '24 16:02 dnet890

Weird, Can I know how many subreddits you are subscribed to? Also try running this and check your console, I have added some error checking. javascript:(function(){try{const e=document.querySelector('.subscription-box a');if(!e){console.error('Subscription box element not found');return;}const t=e.href.split('/r/')[1].split('+'),n=JSON.stringify(t,null,2),o=new Blob([n],{type:'application/json'}),c=Object.assign(document.createElement('a'),{href:URL.createObjectURL(o),download:'rdx_subs.json'});document.body.appendChild(c).click(),document.body.removeChild(c);}catch(e){console.error('Error occurred:',e);}})();

Basically what the script does is, it extracts subs names from that "Multireddit of your subs" link and adds them to a JSON file and downloads that.

avadhesh18 avatar Feb 01 '24 16:02 avadhesh18

there are 258 subreddits and here is the error message log image

BTW, I got another alt account with 134 subreddits and it just download json files without any problems.

dnet890 avatar Feb 01 '24 23:02 dnet890

I think the issue is due to the size of the URL, here are other reddit projects having the same issue.

Cannot import large amount of Subscriptions #352

https://codeberg.org/teddit/teddit/issues/159#issuecomment-180925

avadhesh18 avatar Feb 02 '24 09:02 avadhesh18

For that instance, https://github.com/redlib-org/redlib, I have my subscription linked with this https://github.com/libreddit/libreddit/wiki/Import-Reddit-Subscriptions .it said the max capacity is around 300. But, I only subscribe less than that. What do you think?

https://old.reddit.com/r/Adguard+Amd+AMDHelp+AMDLaptops+Android+androidapps+AndroidGaming+AndroidHelp+AndroidMasterRace+AndroidQuestions+anime+anime_titties+animemusic+AnimePics+animepiracy+Animewallpaper+AnimeWallpapersSFW+announcements+apolloapp+apollosideloaded+AppHookup+AppHunt+apps+archlinux+AskAJapanese+AskARussian+avoidchineseproducts+bali+Bitwarden+BoostForReddit+brave+brave_browser+chiba+cloudstorage+CloudStorageDiscounts+commandline+DataHoarder+deals+DeckSupport+Discord+discordapp+DIYJapan+DonovanDazs+duckduckgo+DystopiaForReddit+edge+elementaryos+epicgames+EpicGamesHelp+EpicGamesPC+expat+expats+Falcom+fediverse+filen_io+finansial+firefox+focusfor_reddit+fossdroid+framework+gadgets+GameDeals+GameDealsFree+GameDealsMeta+Games+gaming+gamingpc+gamingsuggestions+getnarwhal+gnome+gog+googleplaydeals+Handhelds+hardware+Health+icedrive+indonesia+indonesian+IndoR4R+indowibu+intel+IntelArc+InternationalNews+ios+iosapps+iosgaming+iphone+iPhoneSE+IVPN+IWantOut+Jakarta+japan+japanese+JapanFinance+japanlife+japannews+japanresidents+JapanTravel+JapanTraveler+JRPG+jualbeliindonesia+KamenRider+kde+kdeneon+Kubuntu+LaptopDeals+LegionGo+Lemmy+LemmyMigration+LifeProTips+lineapp+linux+linux4noobs+linux_devices+linux_gaming+LinuxCrackSupport+linuxhardware+linuxmasterrace+linuxmint+linuxquestions+logitech+Luna4Reddit+macgaming+MacGamingOSx+mangapiracy+mangarockapp+ManjaroLinux+MAS_Activator+Mastodon+MechanicalKeyboards+microsoft+MicrosoftTeams+mihonapp+minipc+MiniPCs+ModCoord+MouseReview+movieleaks+movingtojapan+mullvadvpn+narwhalapp+Nokia+Notesnook+NuPhy+nvidia+opendirectories+OpenInvites+opensource+OpenSourceApps+operabrowser+ParsecGaming+pcgaming+pcgaming_news+pcgamingtechsupport+pcloud+pCloud_uncensored+pcmasterrace+PeaZip+photon_reddit+Piracy+pop_os+privacy+PrivacyGuides+privacyhardware+privacypostIO+privacytoolsIO+PrivateInternetAccess+ProtonDrive+ProtonMail+ProtonPass+ProtonVPN+PushBullet+Pyongyang+radeon+realAMD+RedditAlternatives+redditnow+redditsync+RedReader+RelayForReddit+reviewvpn+russian+Saitama+samsung+Save3rdPartyApps+science+sciences+ScienceUncensored+sehat+Session_Messenger+sideloaded+sideloading+sideloadly+signal+SignalGroups+Simplelogin+smallformfactor+software+sony+SonyXperia+StandardNotes+StartpageSearch+Steam+Steam_Link+steamdeals+SteamDeck+steamdeck_linux+SteamDeckCheck+SteamDeckCommunity+SteamDeckHandheld+steamdecksupport+SteamDeckTricks+SteamOS+surfshark+SyncforLemmy+tech+technews+TechNewsNow+TechNewsTomorrow+technology+TechnologyPorn+TechnologyProTips+techsupport+Telegram+Thunderbird+Tokusatsu+Tokyo+trackers+trackersignups+TrodditForReddit+tuxedocomputers+Ubuntu+UbuntuMATE+Ultraman+UnethicalLifeProTips+unixporn+valve+ValveSteamDeck+VeePN_Security+visualnovels+vivaldibrowser+VPN+VPN_Reviews+vpnreviews+VPNTorrents+WebTorrent+Wechat+WeChatVerifications+WeChatVerify+whatsapp+win_ame+windows+Windows10+Windows11+WindowsOnDeck+Windscribe+worldnews+Yokohama

dnet890 avatar Feb 02 '24 09:02 dnet890

I had an issue with that in firefox. Also, there is a cap on the amount of subs you can get from the multireddit. I wrote up this little script to run in the dev tools console that exports it. It uses the 'My Subreddits' dropdown on the upper left:

EDIT: It only works when you have RES installed. Otherwise one from my next post should work

document.getElementById('srDropdownContainer').click(); setTimeout(() => {const subnames=Array.prototype.filter.call(document.getElementById('srList').getElementsByTagName('tr'), el => el.children[0].tagName != 'TH').map(c => c.firstChild.firstChild.href.split('/r/')[1]).filter(c => c).map(c => c.substring(0, c.length - 1));const jsonData=JSON.stringify(subnames,null,2);const blob=new Blob([jsonData],{type:'application/json'});const downloadLink=Object.assign(document.createElement('a'),{href:URL.createObjectURL(blob),download:'rdx_subs.json'});document.body.appendChild(downloadLink).click()&&document.body.removeChild(downloadLink);}, 2000)

dr-carrot avatar Feb 06 '24 21:02 dr-carrot

@dr-carrot I tried that script and it does not worked

Snipaste_2024-02-07_09-28-41 Snipaste_2024-02-07_09-28-21

dnet890 avatar Feb 07 '24 00:02 dnet890

@dtantono Ah, I see. That script I posted works for RES. This one should work for normal old reddit:

document.getElementsByClassName('srdrop')[0].click(); setTimeout(() => {const subnames=Array.prototype.map.call(document.getElementsByClassName('srdrop')[1].children, c => c.href.split('/r/')[1]?.slice(0 ,-1)).filter(c => c);const jsonData=JSON.stringify(subnames,null,2);const blob=new Blob([jsonData],{type:'application/json'});const downloadLink=Object.assign(document.createElement('a'),{href:URL.createObjectURL(blob),download:'rdx_subs.json'});document.body.appendChild(downloadLink).click()&&document.body.removeChild(downloadLink);}, 1000)

dr-carrot avatar Feb 07 '24 01:02 dr-carrot

I use Chromium on Windows 10 without any extensions and it does not work Snipaste_2024-02-07_10-44-19 Snipaste_2024-02-07_10-43-32

dnet890 avatar Feb 07 '24 01:02 dnet890

I'm not really familiar with the chrome command palette (this is actually the first time I've ever seen it). Try just pasting it into the console (and you would probably need to allow pasting if you trust the js) 302828239-58aa420b-b67a-49de-b34a-780d6a6a65ae

dr-carrot avatar Feb 07 '24 02:02 dr-carrot

Thanks I have Firefox and it works. But, I don't think this is a permanent solution because majority people use chromium based browsers

dnet890 avatar Feb 07 '24 02:02 dnet890

That's strange. It worked when I tried it in google chrome and I even downloaded chromium and it worked there, too. I'm not sure what the optimal way to do this is or what the maintainers might have in mind. I just happened to try this today, found it didn't work, and modified the script until it did


A little extension might be the most flexible and reliable way to do this. Or maybe there is one that exists that could be leveraged

dr-carrot avatar Feb 07 '24 02:02 dr-carrot