Tweeps Bookmarklet
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
/* Bookmarklet generated by GPT-3 when presented with tweeps_bookmarklet.js and the prompt: | |
change the above bookmarklet to do mastodon searches instead using a function called generate_mastodon_search_links | |
and the url https://search.noc.social/?search={url encoded name from selection} */ | |
javascript:(function()%7Bfunction generate_mastodon_search_links() %7Bvar text %3D ""%3Bif (window.getSelection) %7Btext %3D window.getSelection().toString()%3B%7D else if (document.selection %26%26 document.selection.type !%3D "Control") %7Btext %3D document.selection.createRange().text%3B%7Dvar list_elements %3D text.replace(%2F%5B%5Ea-zA-Z%2C %5D%2Fg%2C "").split("%2C")%3Bvar output %3D "<ul>"%3Bfor (var i %3D 0%3B i < list_elements.length%3B i%2B%2B) %7Boutput %2B%3D "<li><a href%3D'https%3A%2F%2Fsearch.noc.social%2F%3Fsearch%3D" %2B list_elements%5Bi%5D %2B "' target%3D'_blank'>" %2B list_elements%5Bi%5D %2B "<%2Fa><%2Fli>"%3B%7Doutput %2B%3D "<%2Ful>"%3Breturn output%3B%7Dfunction openDiv(html) %7Bvar div %3D document.createElement("div")%3Bvar s %3D div.style%3Bs.position %3D "absolute"%3Bs.top %3D "0px"%3Bs.right %3D "0px"%3Bs.width %3D "400px"%3Bs.height %3D "100%25"%3Bs.overflow %3D "scroll"%3Bs.backgroundColor %3D "%23fff"%3Bs.zIndex %3D "9999"%3Bdiv.innerHTML %3D html%3Bdocument.body.appendChild(div)%3B%7DopenDiv(generate_mastodon_search_links())%7D)() |
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 a list of Twitter search links for names listed in a comma delimited list, such as is common for technical paper author listings */ | |
/* JS Generated by GPT-3 using the prompts in the comments... */ | |
/* Generate a javascript function that captures the selected text, removes all characters except a-zA-Z, space and comma, | |
then splits the string by comma into an array of list_elements and outputs a <ul><li> of links in a new window with each link | |
in the format | |
"https://twitter.com/search?q=" + list_element + "&src=typed_query&f=user" */ | |
function generate_twitter_search_links() { | |
var text = ""; | |
if (window.getSelection) { | |
text = window.getSelection().toString(); | |
} else if (document.selection && document.selection.type != "Control") { | |
text = document.selection.createRange().text; | |
} | |
var list_elements = text.replace(/[^a-zA-Z, ]/g, "").split(","); | |
var output = "<ul>"; | |
for (var i = 0; i < list_elements.length; i++) { | |
output += "<li><a href='https://twitter.com/search?q=" + list_elements[i] + "&src=typed_query&f=user' target='_blank'>" + list_elements[i] + "</a></li>"; | |
} | |
output += "</ul>"; | |
return output; | |
} | |
/* Generate javascript that opens a new absolutely positioned, scrollable div, positioned in the top right corner | |
of the page width a width of 400px and 100% height, then write "hello world" into the div */ | |
function openDiv(html) { | |
var div = document.createElement("div"); | |
var s = div.style; | |
s.position = "absolute"; | |
s.top = "0px"; | |
s.right = "0px"; | |
s.width = "400px"; | |
s.height = "100%"; | |
s.overflow = "scroll"; | |
//manually added background, z-index | |
s.backgroundColor = "#fff"; | |
s.zIndex = "9999"; | |
div.innerHTML = html; | |
document.body.appendChild(div); | |
} | |
//manually composited | |
openDiv(generate_twitter_search_links()) |
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
/* Bookmarklet generated from tweeps.js using default settings at https://mrcoles.com/bookmarklet/ */ | |
javascript:(function()%7Bfunction generate_twitter_search_links() %7Bvar text %3D ""%3Bif (window.getSelection) %7Btext %3D window.getSelection().toString()%3B%7D else if (document.selection %26%26 document.selection.type !%3D "Control") %7Btext %3D document.selection.createRange().text%3B%7Dvar list_elements %3D text.replace(%2F%5B%5Ea-zA-Z%2C %5D%2Fg%2C "").split("%2C")%3Bvar output %3D "<ul>"%3Bfor (var i %3D 0%3B i < list_elements.length%3B i%2B%2B) %7Boutput %2B%3D "<li><a href%3D'https%3A%2F%2Ftwitter.com%2Fsearch%3Fq%3D" %2B list_elements%5Bi%5D %2B "%26src%3Dtyped_query%26f%3Duser' target%3D'_blank'>" %2B list_elements%5Bi%5D %2B "<%2Fa><%2Fli>"%3B%7Doutput %2B%3D "<%2Ful>"%3Breturn output%3B%7Dfunction openDiv(html) %7Bvar div %3D document.createElement("div")%3Bvar s %3D div.style%3Bs.position %3D "absolute"%3Bs.top %3D "0px"%3Bs.right %3D "0px"%3Bs.width %3D "400px"%3Bs.height %3D "100%25"%3Bs.overflow %3D "scroll"%3Bs.backgroundColor %3D "%23fff"%3Bs.zIndex %3D "9999"%3Bdiv.innerHTML %3D html%3Bdocument.body.appendChild(div)%3B%7DopenDiv(generate_twitter_search_links())%7D)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment