Created
August 20, 2020 16:30
-
-
Save double-beep/189db199b94446020ce61957f97f029f to your computer and use it in GitHub Desktop.
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 FIRE translator | |
| // @version 0.1 | |
| // @description Automatically translates FIRE reports for you. | |
| // @author double-beep | |
| // @match *://chat.stackexchange.com/transcript/* | |
| // @match *://chat.meta.stackexchange.com/transcript/* | |
| // @match *://chat.stackoverflow.com/transcript/* | |
| // @match *://chat.stackexchange.com/users/120914/* | |
| // @match *://chat.stackexchange.com/users/120914?* | |
| // @match *://chat.stackoverflow.com/users/3735529/* | |
| // @match *://chat.stackoverflow.com/users/3735529?* | |
| // @match *://chat.meta.stackexchange.com/users/266345/* | |
| // @match *://chat.meta.stackexchange.com/users/266345?* | |
| // @include /^https?://chat\.meta\.stackexchange\.com/(?:rooms/|search.*[?&]room=)(?:89|1037|1181)(?:[&/].*$|$)/ | |
| // @include /^https?://chat\.stackoverflow\.com/(?:rooms/|search.*[?&]room=)(?:41570|90230|111347|126195|167826|170175)(?:[&/].*$|$)/ | |
| // @include /^https?://chat\.stackexchange\.com/(?:rooms/|search.*[?&]room=)(?:11|95|201|388|468|511|2165|3877|8089|11540|22462|24938|34620|35068|38932|47869|56223|58631|59281|61165|65945|84778|96491)(?:[&/].*$|$)/ | |
| // @grant GM_addStyle | |
| // ==/UserScript== | |
| (function() { | |
| GM_addStyle('.translate-button { margin-right: 10px !important; float: right; }'); | |
| window.addEventListener('fire-popup-appeared', function() { // FIRE popup appeared | |
| const reportBody = document.querySelector('.fire-reported-post').innerText; | |
| const reportBodyEncoded = encodeURIComponent(reportBody); | |
| const googleTranslateUrl = `https://translate.google.com/?source=osdd#auto|auto|${reportBodyEncoded}`; | |
| const translateButtonHtml = `<a href="${googleTranslateUrl}" target="_blank" fire-tooltip="Open on Google Translate" class="button translate-button">Translate</a>`; | |
| document.querySelector('.fire-metasmoke-button').insertAdjacentHTML('afterend', translateButtonHtml); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment