Last active
December 30, 2025 16:42
-
-
Save silver-mixer/ba6f5fb1e1eda9822988a56e2c9dceca to your computer and use it in GitHub Desktop.
[UserScript] Extract and display user unique id in twitter
This file contains hidden or 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 Twitter User ID Extractor | |
| // @namespace https://estar-lab.net/ | |
| // @version 5.0 | |
| // @description ユーザの固有IDを抽出します。 | |
| // @author silver-mixer | |
| // @match https://x.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com | |
| // @grant none | |
| // ==/UserScript== | |
| (() => { | |
| 'use strict'; | |
| // Extract UserID from UserByScreenName | |
| const oXHROpen = XMLHttpRequest.prototype.open; | |
| XMLHttpRequest.prototype.open = function(){ | |
| const openURL = arguments[1]; | |
| if(/\/UserByScreenName/.test(openURL)){ | |
| this.addEventListener('load', () => { | |
| const data = JSON.parse(this.responseText); | |
| const screenName = data?.data?.user?.result?.core?.screen_name; | |
| const userId = data?.data?.user?.result?.rest_id; | |
| if(screenName !== null && userId !== null){ | |
| if(location.href.includes('/' + screenName)){ | |
| const linkTag = document.getElementById('_tuie_link'); | |
| if(linkTag !== null){ | |
| console.log('update link'); | |
| linkTag.href = `https://x.com/intent/user?user_id=${userId}`; | |
| linkTag.textContent = `@${screenName} (${userId})`; | |
| }else{ | |
| console.log('create link'); | |
| const infoPane = document.querySelectorAll('.css-175oi2r.r-1adg3ll.r-6gpygo')[2]; | |
| infoPane.insertAdjacentHTML('beforeend', `<div><a id="_tuie_link" style="color: rgb(139, 152, 165);" href="https://x.com/intent/user?user_id=${userId}">@${screenName} (${userId})</a></div>`); | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| oXHROpen.apply(this, arguments); | |
| }; | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Twitter User ID Extractor
簡易バージョン履歴