Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The javaScript does not work to download subscriptions #3

Open
dnet890 opened this issue Feb 1, 2024 · 14 comments
Open

The javaScript does not work to download subscriptions #3

dnet890 opened this issue Feb 1, 2024 · 14 comments

Comments

@dnet890
Copy link

dnet890 commented Feb 1, 2024

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?

@avadhesh18
Copy link
Owner

  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.

@dnet890
Copy link
Author

dnet890 commented Feb 1, 2024

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
2024-02-01.21-37-04.mp4
2024-02-01_21-36_1 2024-02-01_21-36
2024-02-01.22-08-27.mp4
2024-02-01.21-37-04.mp4
2024-02-01_21-36_1
2024-02-01.22-08-27.mp4
2024-02-01_21-36

@dnet890
Copy link
Author

dnet890 commented Feb 1, 2024

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

@avadhesh18
Copy link
Owner

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.

@dnet890
Copy link
Author

dnet890 commented Feb 1, 2024

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.

@avadhesh18
Copy link
Owner

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

@dnet890
Copy link
Author

dnet890 commented Feb 2, 2024

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

@dr-carrot
Copy link

dr-carrot commented Feb 6, 2024

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)

@dnet890
Copy link
Author

dnet890 commented Feb 7, 2024

@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

@dr-carrot
Copy link

@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)

@dnet890
Copy link
Author

dnet890 commented Feb 7, 2024

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

@dr-carrot
Copy link

dr-carrot commented Feb 7, 2024

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

@dnet890
Copy link
Author

dnet890 commented Feb 7, 2024

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

@dr-carrot
Copy link

dr-carrot commented Feb 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants