Gatech Canvas Team Announcement Script for TA

Perform multiple actions

Mint 2024.01.17.. Lásd a legutóbbi verzió

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Gatech Canvas Team Announcement Script for TA
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Perform multiple actions
// @author       thuanvo09
// @match        https://gatech.instructure.com/groups/*/discussion_topics/new?is_announcement=true
// @grant        window.close
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // For open multiple tabs using Chrome console

    /*



    const start_team_id = 356322
    const end_team_id = 356348

    // teams left
    const ignore = [356340, 356342]

function urlGen(team_id) {
        return `https://gatech.instructure.com/groups/${team_id}/discussion_topics/new?is_announcement=true`
    }

    for (let i = start_team_id; i <= end_team_id; i+=2) {
        if (ignore.includes(i)) {
            continue
        }
        const url = urlGen(i)
        window.open(url, '_blank')
    }




    */

    const post_title = "This is a title";

    // convert markdown to html, use html in the content

    const post_content =
`
<h2>Hello</h2>
<p><em>This&nbsp;</em></p>
<h3><strong>is&nbsp;</strong></h3>
<p>an</p>
<pre>annoucement</pre>
`;

    function openAndModify() {
        window.onload = function () {
            setTimeout(() => {

                // title
                const title_inp = document.getElementById("discussion-title");
                title_inp.value = post_title;

                document.getElementsByClassName("css-lgvgsl-view--inlineBlock-baseButton")[3].click()

                // content
                const content_inp = document.getElementById("discussion-topic-message11")
                content_inp.value = post_content


                document.getElementsByClassName("css-lgvgsl-view--inlineBlock-baseButton")[0].click()

                // BE CAREFUL WITH THIS ACTION, NEED TO TEST
                // SUBMIT
                // document.getElementsByClassName("submit_button")[0].click()

                //                 console.log('closing')
                //                 window.close()


            }, 2000);
        };
    }

    openAndModify();



})();