a workaround to bypass Instagram login page
< Feedback on Bypass Instagram Login Redirects
Hey thanks for the feedback, what was the issue exactly that was preventing you from changing the viewer?
Hey thanks for the feedback, what was the issue exactly that was preventing you from changing the viewer?
The issue was the GM.getValue
and GM.setValue
functions not properly setting or retrieving the viewerConfig
values, which prevents the switch between viewers. I solved this by using localStorage
instead of GM
.
I see, this is usually fixed if you delete the script and reinstall it again..
I also just updated the script to (v2.1) Can you please confirm if you still have problems after updating to this version?
I see, this is usually fixed if you delete the script and reinstall it again..
I also just updated the script to (v2.1) Can you please confirm if you still have problems after updating to this version?
Updated it and didn't fix it, I also went ahead reinstalled it (as in delete and install) that also didn't fix it. My solution above still works tho.
Ok I guess I'll have to switch to using localStorage (or some hybrid approach) for the next update, thank you for your time..
Ok I guess I'll have to switch to using localStorage (or some hybrid approach) for the next update, thank you for your time..
No problem, glad I could help.
Not sure what happened but after updating the script to 2.1 then pasting the solution above stopped showing the little menu pick in the extension. Couldn't be bothered to spend debugging myself so I asked ChatGPT (LoL), and it gave this as a response.
The issue with the menu not showing up is likely due to the fallback implementation for GM_getValue
and GM_setValue
. These functions aren't handling the registration of the menu commands properly in your script. The fallback functions you're using for GM_getValue
and GM_setValue
are replacing the Tampermonkey-provided APIs, which is likely causing the menu registration to fail.
Here’s how you can fix it:
Remove the fallback implementation for GM_getValue
and GM_setValue
. Since these are already provided by Tampermonkey, you should not override them.
Ensure the GM_registerMenuCommand
is correctly defined and accessible. If it’s not working correctly, the menu won’t show up.
Here is the updated code:
// ==UserScript==
// @name Bypass Instagram Login Redirects
// @namespace http://tampermonkey.net/
// @version 2.1
// @description a workaround to bypass Instagram login page
// @author VeloxMoto
// @match *://*/*
// @run-at document-body
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @license GNU GPLv3
// @downloadURL https://update.greasyfork.org/scripts/420604/Bypass%20Instagram%20Login%20Redirects.user.js
// @updateURL https://update.greasyfork.org/scripts/420604/Bypass%20Instagram%20Login%20Redirects.meta.js
// ==/UserScript==
(async () => {
// Instagram profile & post URLs regex
const instaProfile = /(? {
mediaId = BigInt(mediaId * 64n) + BigInt(alphabet.indexOf(letter));
});
return currentViewer.reverseMediaId ? mediaId.toString().split("").reverse().join("") : mediaId;
}
}
function getUsername(url) {
url = decodeURIComponent(url);
return url.match(instaProfile)[1];
}
// Address checker function
(() => {
const address = window.location.href;
if (/next=(?:\/|%2f)(?!accounts|explore|developer|reel)[a-zA-Z._0-9]{3,}/i.test(address)) {
window.location.href = currentViewer.profilePrefix + getUsername(address);
} else if (/next=(?:\/|%2f)(p|reel)(?:\/|%2f)[a-zA-Z._0-9-]+/i.test(address)) {
window.location.href = currentViewer.postPrefix + getMediaId(address);
}
})();
if (!document.cookie.includes("ds_user_id")) {
let aTags = [];
const body = document.documentElement || document.body;
const observer = new MutationObserver(() => {
aTags = [...new Set([...aTags, ...document.querySelectorAll("a")])];
for (let x of aTags) {
try {
if (instaProfile.test(decodeURIComponent(x.href))) {
x.addEventListener("click", event => event.stopPropagation(), true);
x.href = currentViewer.profilePrefix + getUsername(x.href);
}
if (instaPost.test(decodeURIComponent(x.href))) {
x.addEventListener("click", event => event.stopPropagation(), true);
x.href = currentViewer.postPrefix + getMediaId(x.href);
}
} catch {} // ignore errors
}
});
observer.observe(body, {
subtree: true,
childList: true,
attributeFilter: ["href"]
});
}
})();
Not sure what happened but after updating the script to 2.1 then pasting the solution above stopped showing the little menu pick in the extension
Oh that's unfortunate.. You could still downgrade to v1.9 and reapply your original fix above if you want, just follow this this link then click the green button to downgrade: https://greasyfork.org/en/scripts/420604-bypass-instagram-login-redirects?version=1198671
Hope this helps :)
P.S. I'm trying to integrate the localStorage method, but I'm still running into some problems, because localStorage is not persistent in incognito mode (i.e it gets deleted after you close the incognito tabs)
P.S. I'm trying to integrate the localStorage method, but I'm still running into some problems, because localStorage is not persistent in incognito mode (i.e it gets deleted after you close the incognito tabs)
The code above the message you send, I checked to see if it has the same incognito issue and no it does not.
The code above the message you send, I checked to see if it has the same incognito issue and no it does not.
I think this code should work as well: https://hastebin.com/share/borelozaxo.javascript
Please try it without any modifications in both a normal tab and incognito, I want to see if it solves your problem.. (don't forget to disable any other duplicates of the same script)
The code above the message you send, I checked to see if it has the same incognito issue and no it does not.
I think this code should work as well: https://hastebin.com/share/borelozaxo.javascript
Please try it without any modifications in both a normal tab and incognito, I want to see if it solves your problem.. (don't forget to disable any other duplicates of the same script)
Sorry for late response, just tested the code in the hastebin. In normal browser mode (not Incog) works fine and able to switch viewer, but in Incog mode it doesn't let you switch and it is stuck on Imignn which is the default. Btw I am using firefox + violentmonkey.
The most recent I've send here doesn't have Incog issue and still lets me switch.
In normal browser mode (not Incog) works fine and able to switch viewer, but in Incog mode it doesn't let you switch
Right, the code in that hastebin uses localStorage in normal tabs and Tampermonkey/Violentmonkey storage in incognito, so your browser seems to have a problem with Violentmonkey storage for some reason..
The most recent I've send here doesn't have Incog issue and still lets me switch.
Your code works in both is because it's using localStorage exclusively, but I'm hesitant to use this approach for everyone because localStorage stores values per domain (i.e. you have to set the viewer for each site you visit) and it won't remember your choice after an incognito session is closed, sorry..
One last request please, If you could try a different browser (Edge, Chrome) to confirm if the issue still exist in other browsers..
Finally, here's a better structured code that uses localStorage in both incognito and normal tabs so it should work for you on Firefox in both cases without any modifications, just in case you don't find any other solution: https://hastebin.com/share/ziyarumeka.javascript
In normal browser mode (not Incog) works fine and able to switch viewer, but in Incog mode it doesn't let you switch
Right, the code in that hastebin uses localStorage in normal tabs and Tampermonkey/Violentmonkey storage in incognito, so your browser seems to have a problem with Violentmonkey storage for some reason..
Your code works in both is because it's using localStorage exclusively, but I'm hesitant to use this approach for everyone because localStorage stores values per domain (i.e. you have to set the viewer for each site you visit) and it won't remember your choice after an incognito session is closed, sorry..
I think you a bit wrong, not because I know better but from what I experienced. It seems the code I provided doesn't have the per site issue, I select a viewer and it auto applies to every site as well as my choice transfers over when I start a new Incog session.
To be clear Incog on Firefox different, as it creates its own isolated instance. As in it will have its own tab history, so if you closed a tab by accident in incog you can't ctrl+shitft+t
to get it back but in firefox's incog you can, as long 1 incog tab/window is open the session is stored until every incog tab/window is closed in which firefox deletes it.
In short, some of the stuff you mention that shouldn't work or is an issue with my specific combination of browser and userscript extension isn't an issue at all.
I've went ahead and tested the latest code you send in the hastebin, and funny enough the issues you mention my script has (even though it doesn't at all whatsoever as mentioned prior) your latest code has this issue.
For starters, whatever viewer I pick in normal mode doesn't transfer over to incog but I can still change it in incog at least. Secondly, I have to set the viewer per site, I first switched it on google.com
but then for duckduckgo.com
it was back at the default viewer.
Hope this helps, again tested on Firefox + violentmonkey. Don't have either edge or chrome installed and not gonna bother installing for this when my main browser is firefox.
Yeah what you're experiencing is a bit weird, but I was getting my information from https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage :
The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions... localStorage data for a document loaded in a "private browsing" or "incognito" session is cleared when the last "private" tab is closed
Can you give me the full code that worked for you in a hastebin so I can test it myself please? (The code snippet above seem to be missing some chunks)
Yeah what you're experiencing is a bit weird, but I was getting my information from https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage :
The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions... localStorage data for a document loaded in a "private browsing" or "incognito" session is cleared when the last "private" tab is closed
Can you give me the full code that worked for you in a hastebin so I can test it myself please? (The code snippet above seem to be missing some chunks)
Here is link to it: https://stellular.net/haste
Thank you, but the code shows this error: https://i.imgur.com/OwvPXsp.png
Thank you, but the code shows this error: https://i.imgur.com/OwvPXsp.png
Sorry, check the link again I have updated it. Pasted wrong, should be correct one now.
This code is very close to the 1.9 version only difference is that it uses a (dash) for GM functions like so: GM_getValue instead of a (period) GM.getValue and there's no use of localStorage..
What's weird is that the latest version (v2.1) also uses the dash method but you're facing problems on that, it's puzzling..
Can you try this code please and let me know what happens: https://hastebin.com/share/gupujegepu.javascript (I understand if you're tired of this and just want to use your version, I just wanted to get to the bottom of this, feel free to move on if you want)
(async () => { // Instagram profile & post URLs regex const instaProfile = /(? reverse mediaId } } // Function to get or set data (fallback to localStorage) const GM_getValue = async (key, defaultValue) => { const value = localStorage.getItem(key); return value ? JSON.parse(value) : defaultValue; }; const GM_setValue = async (key, value) => { localStorage.setItem(key, JSON.stringify(value)); }; // Default viewer const defaultViewer = new Viewer("imginn", "https://imginn.com/", "https://imginn.com/p/", "shortcode"); var currentViewer = await GM_getValue("viewerConfig", defaultViewer); // Menu Options: const viewerOptions = [ { name: "Picnob", function: picnob }, { name: "Picuki", function: picuki }, { name: "Dumpor", function: dumpor }, { name: "imginn", function: imginn } ]; // ✔️ current option: for (let item of viewerOptions) { if (currentViewer.name === item.name) { item.name = currentViewer.name + " ✔️"; GM.registerMenuCommand(item.name, item.function); } else { GM.registerMenuCommand(item.name, item.function); } } // Switching viewers handler functions async function switchViewer(name, profilePrefix, postPrefix, identifier, reverseMediaId) { if (currentViewer.name !== name) { await GM_setValue("viewerConfig", new Viewer(name, profilePrefix, postPrefix, identifier, reverseMediaId)); location.reload(); // reload page alert(`Viewer is now set to ${name}`); } } async function picuki() { await switchViewer("Picuki", "https://picuki.com/profile/", "https://picuki.com/media/", "mediaId", false); } async function dumpor() { await switchViewer("Dumpor", "https://dumpor.com/v/", "https://dumpor.com/c/", "mediaId", true); } async function imginn() { await switchViewer("imginn", "https://imginn.com/", "https://imginn.com/p/", "shortcode", false); } async function picnob() { await switchViewer("Picnob", "https://www.picnob.com/profile/", "https://www.picnob.com/post/", "shortcode", false); } function getMediaId(url) { const shortcode = url.match(instaPost)[1]; if (currentViewer.identifier === "shortcode") { return shortcode; } else if (currentViewer.identifier === "mediaId") { const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'; let mediaId = BigInt(0); shortcode.split("").forEach(letter => { mediaId = BigInt(mediaId * 64n) + BigInt(alphabet.indexOf(letter)); }); return currentViewer.reverseMediaId ? mediaId.toString().split("").reverse().join("") : mediaId; } } function getUsername(url) { url = decodeURIComponent(url); return url.match(instaProfile)[1]; } // Address checker function (() => { const address = window.location.href; if (/next=(?:\/|%2f)(?!accounts|explore|developer|reel)[a-zA-Z._0-9]{3,}/i.test(address)) { window.location.href = currentViewer.profilePrefix + getUsername(address); } else if (/next=(?:\/|%2f)(p|reel)(?:\/|%2f)[a-zA-Z._0-9-]+/i.test(address)) { window.location.href = currentViewer.postPrefix + getMediaId(address); } })(); if (!document.cookie.includes("ds_user_id")) { let aTags = []; const body = document.documentElement || document.body; const observer = new MutationObserver(() => { aTags = [...new Set([...aTags, ...document.querySelectorAll("a")])]; for (let x of aTags) { try { if (instaProfile.test(decodeURIComponent(x.href))) { x.addEventListener("click", event => event.stopPropagation(), true); x.href = currentViewer.profilePrefix + getUsername(x.href); } if (instaPost.test(decodeURIComponent(x.href))) { x.addEventListener("click", event => event.stopPropagation(), true); x.href = currentViewer.postPrefix + getMediaId(x.href); } } catch {} // ignore errors } }); observer.observe(body, { subtree: true, childList: true, attributeFilter: ["href"] }); } })();
This one uses localStorage, this was based on 1.9 than after the 2.1 update I tried using that and didnt work but when I try go back using this code didn't work either so I ended up asking ChatGPT to fix 2.1 and gave that.
This code is very close to the 1.9 version only difference is that it uses a (dash) for GM functions like so: GM_getValue instead of a (period) GM.getValue and there's no use of localStorage..
What's weird is that the latest version (v2.1) also uses the dash method but you're facing problems on that, it's puzzling..
Can you try this code please and let me know what happens: https://hastebin.com/share/gupujegepu.javascript (I understand if you're tired of this and just want to use your version, I just wanted to get to the bottom of this, feel free to move on if you want)
Tested, and so far have to set per site still. As well as your picks dont transfer between each mode.
> This one uses localStorage, this was based on 1.9 than after the 2.1 update I tried using that and didnt work but when I try go back using this code didn't work either so I ended up asking ChatGPT to fix 2.1 and gave that.
I see, very weird..
> Tested, and so far have to set per site still. As well as your picks dont transfer between each mode.
Oops shared the wrong one, sorry, here's the right one: https://hastebin.com/share/ukiyufufuv.javascript
It sounds like you've been through quite a journey trying to navigate the differences between versions 1.9 and 2.1. The switch from `GM.getValue` to `GM_getValue` and the challenges with localStorage compatibility can certainly be frustrating, especially when you expect older code to work and it doesn't. It's interesting that version 2.1 is still giving you trouble despite seemingly using the correct syntax. Testing the code shared on Hastebin might shed some light on the issue, but I completely understand if you're ready to move on. Sometimes, the best solution is the one that works consistently for your needs, even if it means sticking with an earlier version. Don't hesitate to prioritize your own workflow and peace of mind—debugging can be exhausting. https://iqratechnology.com/
> This one uses localStorage, this was based on 1.9 than after the 2.1 update I tried using that and didnt work but when I try go back using this code didn't work either so I ended up asking ChatGPT to fix 2.1 and gave that.
I see, very weird..
> Tested, and so far have to set per site still. As well as your picks dont transfer between each mode.
Oops shared the wrong one, sorry, here's the right one: https://hastebin.com/share/ukiyufufuv.javascript
Tested the correct one you send just now, and it has no issues whatsoever. Viewer changes transfer between each mode, and no longer is per site. Nice job, I have updated the rating to Good.
Aha so it was as simple as adding "await" to the GM functions (I will update the script soon to add this), thank you for helping me debug this and for the rating :)
Aha so it was as simple as adding "await" to the GM functions (I will update the script soon to add this), thank you for helping me debug this and for the rating :)
No problem, happy to help
Recently I am unable to change which viewer. Luckily after tinkering myself I was able to fix the issue.
Here is the updated and working code that lets you switch the viewer, just copy paste it in.