Skip to content

Instantly share code, notes, and snippets.

@cameri
Last active June 12, 2022 11:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cameri/114245e07287afc8bc8638013b1ea12a to your computer and use it in GitHub Desktop.
Save cameri/114245e07287afc8bc8638013b1ea12a to your computer and use it in GitHub Desktop.
[
"ed1d0e1f743a7d19aa2dfb0162df73bacdbc699f67cc55bb91a98c35f7deac69",
"fd3fdb0d0d8d6f9a7667b53211de8ae3c5246b79bdaf64ebac849d5148b5615f",
"e668a111aa647e63ef587c17fb0e2513d5c2859cd8d389563c7640ffea1fc216",
"1bbb8324577ac089607e45813bac499ebdab4621d029f8c02b2c82b4410fd3f4",
"51535ad9f0e13a810f73ea8829a79b3733bd1fffb767c4885990b02f59103a13",
"2508ed2c2ab3f6728a880fafbc0895a2afeacbb74eb69847255fb60564af0d85",
"3707f1efc7515524dce41d3bf50bfd9fdaed3494620b5f94fcf16d2766da4ec2",
"dbab9040bc1f0c436b0f92f517702498358edc1fde2c7884d0e1036c739d44f3",
"ad5aab5be883a571ea37b231cd996d37522e77d0f121cedfd6787b91d848268e",
"8f87ac34eb27a86fc917866fbc9016429bd89cf1d0d27a038a8eaac4c62c63e5",
"c2bb5d6529095edbfbdbe3f136175c146c6706526325b32da881c7c34c7b1ab8",
"52cb4b34775fa781b6a964bda0432dbcdfede7a59bf8dfc279cbff0ad8fb09ff",
"3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d",
"1d643df20fb811b33c3cfb04c72db04c6ae031dbf68f613ba45407cbdd9446b6",
"904ea00a4a245559d6184be5c6e2cf2c66ea7fc91eb5f1eb5349506d19d63a11",
"7e88f589d2677ea4a863c72af5d0e85fbe1d3db111667c50d33fa42196a1afc0",
"35d26e4690cbe1a898af61cc3515661eb5fa763b57bd0b42e45099c8b32fd50f",
"f0bed2e11260f0f77f781db928f40a34c18713fda1918d3be996f91d0776e985",
"3878d95db7b854c3a0d3b2d6b7bf9bf28b36162be64326f5521ba71cf3b45a69",
"168b5acb915b1ea5bcdefb460823fd9cd56399da75a8da78459fa1a1bdc7df32",
"ef79cecbc8d145a1ee3be74fb24143ca073615015ded37bd09d55e0e6e58a48b",
"565152b2d1793a253cba282588a4b287b0ab2acbe7faa7021ea0dced39d33716",
"b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9",
"65d1973929f1d9933cef0f8920eac1f74bccf7e4beb6e5d3c1047e25f21d2270",
"29a96708b9c67d35faa6bc43962d85227f86b392588bab86560809195727324e",
"5665a37f248e0290538c883d0fe9c94770ddfd723e04bb29e7f51f09bcfe83d2"
]
{
"wss://nostr-pub.wellorder.net": {
"read": true,
"write": true
},
"wss://relayer.fiatjaf.com": {
"read": true,
"write": true
},
"wss://nostr.rocks": {
"read": true,
"write": true
},
"wss://nostrrr.bublina.eu.org": {
"read": true,
"write": true
},
"wss://nostr-relay.freeberty.net": {
"read": true,
"write": true
},
"wss://freedom-relay.herokuapp.com/ws": {
"read": true,
"write": true
}
}
/************************
* Use at your own risk *
************************/
(async () => {
const gistId = 'yourGistId';
const response = await fetch(`https://api.github.com/gists/${gistId}`, {
headers: {
'Accept': 'application/vnd.github.v3+json',
},
})
const {
files: {
'nostr_pubring.json': {
content: pubring
},
'nostr_relays.json': {
content: relays,
},
}
} = await response.json();
const existingPubring = JSON.parse((localStorage.getItem('following') || '').substr(9)) || [];
const existingRelays = JSON.parse(localStorage.getItem('relays').substr(9)) || {};
const pulledPubring = JSON.parse(pubring);
const pulledRelays = JSON.parse(relays);
const newPubring = Array.from(new Set([...pulledPubring, ...existingPubring]));
const newRelays = { ...pulledRelays, ...existingRelays };
localStorage.setItem('following', `__q_objt|${JSON.stringify(newPubring)}`)
localStorage.setItem('relays', `__q_objt|${JSON.stringify(newRelays)}`)
})();
/* run this on the browser to push your followers' pubkeys to a gist */
(async () => {
const username = 'yourUser';
const personalToken = 'yourTokenHere'; // create one with gist scope here: https://github.com/settings/tokens
const gistId = 'yourGistId'; // must already exist, this script does not create a new gist
const pubring = JSON.parse(localStorage.getItem("following").substr(9));
const relays = JSON.parse(localStorage.getItem("relays").substr(9));
const body = {
files: {
'nostr_pubring.json': {
content: JSON.stringify(pubring, undefined, 2),
},
'nostr_relays.json': {
content: JSON.stringify(relays, undefined, 2),
},
}
}
await fetch(`https://api.github.com/gists/${gistId}`, {
method: 'PATCH',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `token ${personalToken}`
},
body: JSON.stringify(body),
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment