Last active
January 8, 2020 10:28
-
-
Save plantvsbirds/ff8829a247d7fd522405 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
/*------------------------get Twitter Ids on page --------------------- | |
| Find twitter IDs of people on page(intended for blocking multiple | |
users) bookmarklet inspired by @mariotaku 's wtb | |
| Author: Hong Lin <[email protected]> | |
License: MIT | |
| See comments below for usage thx. | |
| https://gist.github.com/plantvsbirds/ff8829a247d7fd522405 | |
*-------------------------------------------------------------------*/ | |
(function (window, $) { | |
if (location.href.indexOf('twitter.com') < 0) { | |
alert('Please run this on twitter page, thx') | |
return | |
} | |
anchors = $('a[data-mentioned-user-id],a[data-user-id]') | |
map = {} | |
anchors.each(function () { | |
elem = $(this) | |
link = elem.attr('href') | |
name = elem.find('b').text() || link.slice(1, link.length - 1) | |
id = elem.attr('data-mentioned-user-id') || elem.attr('data-user-id') | |
if (id == '0') | |
id = 'Visit profile page and run again please. <a href="' + link + '">Click Here</a>' | |
map[id] = name | |
}) | |
promptText = [ | |
'', | |
'All Twitter accounts found on page', | |
'' | |
] | |
ansInLines = Object.keys(map).map(function (k) { | |
return '[' + map[k] + '] : '+ k +' ' | |
}) | |
finalText = promptText | |
.concat(ansInLines) | |
.concat(promptText) | |
.concat(['<button type="button" onclick="window.open(\'\', \'_self\', \'\'); window.close();">Close</button>']) | |
.join('<br>') | |
alertWindow = window.open() | |
alertWindow.document.write(finalText) | |
if(!alertWindow || alertWindow.closed || typeof alertWindow.closed=='undefined') { | |
alert('Disable your popup blocking plz') | |
} | |
})(window, jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this as bookmarklet.
Ctrl + D
to add this page. Then clickEDIT
, change the address to following(just minified version. no harmful stuff fucking with you)
When on twitter page, just click the bookmark you added to run script.