Skip to content

Instantly share code, notes, and snippets.

@nhdinh
Last active October 2, 2023 04:25
Show Gist options
  • Save nhdinh/ed3e1f955d4d38574336ad0557ae088c to your computer and use it in GitHub Desktop.
Save nhdinh/ed3e1f955d4d38574336ad0557ae088c to your computer and use it in GitHub Desktop.
Save data from testIO
// ==UserScript==
// @name IssueSaver
// @namespace https://gist.github.com/nhdinh/ed3e1f955d4d38574336ad0557ae088c
// @downloadURL https://gist.github.com/nhdinh/ed3e1f955d4d38574336ad0557ae088c/raw/tampermonkey-testio-nhdinh.user.js
// @updateURL https://gist.github.com/nhdinh/ed3e1f955d4d38574336ad0557ae088c/raw/tampermonkey-testio-nhdinh.user.js
// @version 0.1.6
// @description Save bugs into my Google Sheet!
// @author You
// @match https://platform.utest.com/testcycles/*/
// @icon https://www.google.com/s2/favicons?sz=64&domain=test.io
// @require https://gist.github.com/BrockA/2625891/raw/waitForKeyElements.js
// @grant GM_addStyle
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @require https://apis.google.com/js/api.js
// ==/UserScript==
const CLIENT_ID = "702339855357-8lckgdo21n9uup6sb31vi5u5gjde1v5b.apps.googleusercontent.com";
const API_KEY = "AIzaSyC_ZGUn2UhWETRS845stPDP53ezvkPmZQ4";
const epochDay = 24 * 60 * 60 * 1000;
// id of Html element to append the button
const WHERE_TO_APPEND = "ntux-nav-header-buttons__item ntux-nav-header-help";
const SAVE_BUTTON = document.createElement("button");
SAVE_BUTTON.className = "btn btn-sm";
SAVE_BUTTON.innerHTML = "Save bug";
const saveButtonClick = async () => {
window.alert("Saving bug...");
};
(async () => {
'use strict';
const addButton = (node) => {
// if there is no element to append the button, return
if (!document.getElementsByClassName(node).length) {
return;
} else {
window.alert(document.getElementsByClassName(node).length);
}
document.getElementsByClassName(node)[0].append(SAVE_BUTTON);
};
// use promise to wait for full page load, then inject the button
addButton();
// if (gapi === undefined) {
// window.alert("gapi is undefined");
// return;
// }
// gapi.load("client:auth2", async () => {
// gapi.client.init({
// apiKey: API_KEY,
// clientId: CLIENT_ID,
// discoveryDocs: ["https://sheets.googleapis.com/$discovery/rest?version=v4"],
// scope: "https://www.googleapis.com/auth/spreadsheets"
// }).then(() => {
// // gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// SAVE_BUTTON.addEventListener("click", saveButtonClick);
// }, (error) => {
// console.log(JSON.stringify(error, null, 2));
// });
// })
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment