Last active
October 9, 2021 09:25
-
-
Save antons/97eb04160e272b606674978567a94aeb to your computer and use it in GitHub Desktop.
Bookmarklet for one-click replies to TestFlight Feedback in App Store Connect.
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 for one-click replies to TestFlight Feedback in App Store Connect. | |
// Automatically fills in tester’s email address, title, and quotes all (or selected) text. | |
// | |
// Add to your browser with Bookmarkleter. | |
// https://chriszarate.github.io/bookmarkleter/ | |
// | |
// Copyright © 2020 Anton Sotkov. MIT Licensed. | |
// | |
var feedbackFields = document.querySelectorAll("[class^='feedback-modal__info-grid'] [class^='display-field']") | |
var feedbackEmail, feedbackDate | |
for (i = 0; i < feedbackFields.length; i++) { | |
var field = feedbackFields[i] | |
var dt = field.querySelector("dt") | |
var dd = field.querySelector("dd") | |
if (dt && dd) { | |
if (dt.innerText === "Email") { | |
feedbackEmail = dd.innerText | |
} | |
if (dt.innerText === "Submitted") { | |
feedbackDate = dd.innerText | |
} | |
} | |
} | |
if (feedbackEmail && feedbackEmail.length > 0) { | |
var emailTitle = "Re: TestFlight Feedback, " + feedbackDate | |
var emailBody = "" | |
var feedbackBodyParagraphs = document.querySelectorAll("[class^='feedback-modal__body-container'] > p") | |
var feedbackBodyParagraphComponents = [] | |
for (i = 0; i < feedbackBodyParagraphs.length; i++) { | |
feedbackBodyParagraphComponents.push(feedbackBodyParagraphs[i].innerText) | |
} | |
var feedbackBodyText = feedbackBodyParagraphComponents.join("\n\n") | |
var quotedText = feedbackBodyText | |
var selectionText = window.getSelection().toString().trim() | |
if (selectionText && selectionText.length > 5 && feedbackBodyText.includes(selectionText)) { | |
quotedText = selectionText | |
} | |
if (quotedText.length > 0) { | |
emailBody = "\n\n" + quotedText.split("\n").map(component => "> " + component).join("\n") + "\n\n\n" | |
} | |
var mailto = "mailto:" + feedbackEmail + "?&subject="+ encodeURI(emailTitle) + "&body=" + encodeURI(emailBody) | |
var mail = document.createElement("a"); | |
mail.href = mailto; | |
mail.click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment