mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 08:07:30 +00:00
Unblock script checks if own network is blocked
This commit is contained in:
parent
6e1e5e6996
commit
36530e5db4
@ -1,4 +1,5 @@
|
||||
const {Readable} = require("stream")
|
||||
const fs = require("fs").promises
|
||||
|
||||
const db = require("../../lib/db")
|
||||
const collectors = require("../../lib/collectors")
|
||||
@ -189,15 +190,13 @@ module.exports = [
|
||||
{
|
||||
route: `/u/(${constants.external.username_regex})/unblock.sh`, methods: ["GET"], code: async ({fill}) => {
|
||||
const username = fill[0]
|
||||
let script = await fs.readFile(__dirname+"/utils/unblock.sh", "utf8")
|
||||
script = script.replace(/<website_origin>/g, constants.website_origin)
|
||||
script = script.replace(/<username>/g, username)
|
||||
return {
|
||||
statusCode: 200,
|
||||
contentType: "text/plain",
|
||||
content:
|
||||
`# Good on you for looking at shell scripts before blindly running them.`
|
||||
+`\n# This script contacts Instagram to get the profile's user ID, then sends the ID to Bibliogram. Bibliogram can take over from there.`
|
||||
+`\ncurl 'https://www.instagram.com/${username}/' -Ss | grep -oE '"id":"[0-9]+"'`
|
||||
+` | head -n 1 | grep -oE '[0-9]+' | curl --data-urlencode 'username=${username}' --data-urlencode 'user_id@-'`
|
||||
+` '${constants.website_origin}/api/suggest_user/v1?plaintext=1'`
|
||||
content: script
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
src/site/api/utils/unblock.sh
Normal file
22
src/site/api/utils/unblock.sh
Normal file
@ -0,0 +1,22 @@
|
||||
# Good on you for looking at shell scripts before blindly running them.
|
||||
# This script contacts Instagram to get the profile's user ID, then sends the ID to Bibliogram. Bibliogram can take over from there.
|
||||
|
||||
# Make a temporary directory
|
||||
tempdir=$(mktemp -d) || exit 1
|
||||
|
||||
# Try to request from Instagram
|
||||
curl 'https://www.instagram.com/<username>/' -Ss > $tempdir/page.html
|
||||
|
||||
if test -s $tempdir/page.html; then
|
||||
# Request returned a page (file not empty)
|
||||
grep -oE '"id":"[0-9]+"' $tempdir/page.html | head -n 1 | grep -oE '[0-9]+' | curl --data-urlencode 'username=<username>' --data-urlencode 'user_id@-' '<website_origin>/api/suggest_user/v1?plaintext=1'
|
||||
else
|
||||
# Request was a redirect
|
||||
echo "Your network is blocked by Instagram."
|
||||
echo "You won't be able to unblock any more profiles."
|
||||
echo "To be unblocked, wait a few hours without running this script."
|
||||
fi
|
||||
|
||||
# Clean up, safely.
|
||||
rm -f $tempdir/page.html
|
||||
rm -d $tempdir
|
@ -24,7 +24,7 @@ html#bibliogram-identifier-blocked
|
||||
| #[a(href="#unblock-on-mac-or-linux") Unblock with shell], no download, Mac and Linux only
|
||||
.hidden-section#unblock-on-mac-or-linux
|
||||
p Open the Terminal application, then paste this code:
|
||||
pre curl -Ss #{website_origin}/u/#{username}/unblock.sh | $SHELL
|
||||
pre curl -Ss #{website_origin}/u/#{username}/unblock.sh | bash
|
||||
li
|
||||
| #[a(href="#unblock-with-userscript") Unblock automatically with userscript], any modern browser
|
||||
.hidden-section#unblock-with-userscript
|
||||
|
Loading…
Reference in New Issue
Block a user