Last active
December 29, 2023 16:50
-
-
Save ryuya0124/79fad15aa00e536cac7cae2bad6283c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Open Instagram App | |
// @version 1.4.0 | |
// @author ryuya | |
// @match *://*.instagram.com/* | |
// @downloadURL https://gist.github.com/ryuya0124/79fad15aa00e536cac7cae2bad6283c6/raw/356b473b688b874398ecc22f41eaba42d2aed3bc/Open%2520Instagram%2520App.user.js | |
// @updateURL https://gist.github.com/ryuya0124/79fad15aa00e536cac7cae2bad6283c6/raw/356b473b688b874398ecc22f41eaba42d2aed3bc/Open%2520Instagram%2520App.user.js | |
// @homepage https://gist.github.com/ryuya0124/79fad15aa00e536cac7cae2bad6283c6 | |
// ==/UserScript== | |
if (window.location.pathname === '/redirect') return; | |
let targetUrl = ''; | |
if (window.location.pathname.includes('/direct')) { | |
// ダイレクトメッセージを処理 | |
targetUrl = 'instagram://direct-inbox'; | |
} else if (window.location.pathname.includes('/explore')) { | |
// Exploreページなど他のページを処理 | |
targetUrl = `instagram://explore${window.location.pathname}${window.location.search}${window.location.hash}`; | |
} else if (window.location.pathname.includes('/reels')) { | |
// Reelsページなど他のページを処理 | |
targetUrl = `instagram://reels${window.location.pathname}${window.location.search}${window.location.hash}`; | |
} else if (window.location.pathname.includes('/stories')) { | |
// Storiesページなど他のページを処理 | |
targetUrl = `instagram://app` | |
} else { | |
// 通常のユーザープロフィールURLを処理 | |
const usernameMatch = window.location.pathname.match(/\/([^\/?]+)/); | |
if (usernameMatch) { | |
const username = usernameMatch[1]; | |
targetUrl = `instagram://user?username=${username}${window.location.search}${window.location.hash}`; | |
} else { | |
// その他のケースを処理、例:投稿 | |
targetUrl = `instagram://media${window.location.pathname}${window.location.search}${window.location.hash}`; | |
} | |
} | |
window.location.href = targetUrl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment