Skip to content

Instantly share code, notes, and snippets.

@walfie
Last active October 18, 2016 02:50
Show Gist options
  • Save walfie/a062a01d16c1a3cea57d0c36a48707fc to your computer and use it in GitHub Desktop.
Save walfie/a062a01d16c1a3cea57d0c36a48707fc to your computer and use it in GitHub Desktop.
Bookmarklet to translate Granblue boss
  1. Create a bookmark with the following "URL" (bookmarklet):

    javascript:!function(){var a=[].slice.call(document.querySelectorAll('.enemy-info>.name')).map(function(a){return a.innerHTML}).filter(function(a){return a.length>0});jQuery.ajax({dataType:'json',url:'http://gbf-raidfinder.aikats.us/api/bosses.json',data:{name:a},traditional:!0,success:function(a){var b=a.raidBosses.map(function(a){return(a.translatedName||{}).value}).filter(function(a){return a});document.querySelector('#frm-post-tweet').value=b.join(' ')}})}();

  2. Go to a raid and open the "Post to Twitter" menu (via "Request Backup" -> "Tweet")

  3. Click the bookmarklet

  4. If a translation is found, it will be inserted into the input box

Note: Translations might not be found for new event bosses that don't have images yet.

Here's a demo video.

// Unminified bookmarklet source
(function() {
var names = [].slice
.call(document.querySelectorAll('.enemy-info>.name'))
.map(function(x) { return x.innerHTML; })
.filter(function(x) { return x.length > 0; })
jQuery.ajax({
dataType: 'json',
url: 'http://gbf-raidfinder.aikats.us/api/bosses.json',
data: { name: names },
traditional: true,
success: function(data) {
var translatedNames = data.raidBosses.map(function(b) {
return (b.translatedName || {}).value;
}).filter(function(x) { return x; });
document.querySelector('#frm-post-tweet').value = translatedNames.join(' ');
}
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment