Open dtantono opened 5 months ago
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.
Hi Thanks for your reply and here are my answers:
https://github.com/avadhesh18/rdx/assets/29157187/5d5e0572-2e5d-4811-8079-03eec729c4d5
https://github.com/avadhesh18/rdx/assets/29157187/af17c83c-39bc-47ad-a605-455dcf036b92
https://github.com/avadhesh18/rdx/assets/29157187/ea048a4b-56b5-4a40-9ad8-c66d3229133a
https://github.com/avadhesh18/rdx/assets/29157187/e227b610-ff7b-4d70-857d-173e757502ba
Sorry to add something. I tested it on Google chrome on Windows 10 and I got same problem like that
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.
there are 258 subreddits and here is the error message log
BTW, I got another alt account with 134 subreddits and it just download json files without any problems.
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
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?
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 I tried that script and it does not worked
@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)
I use Chromium on Windows 10 without any extensions and it does not work
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)
Thanks I have Firefox and it works. But, I don't think this is a permanent solution because majority people use chromium based browsers
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
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?