Greasy Fork

Greasy Fork is available in English.

Gatech Canvas Team Announcement Script for TA

Perform multiple actions

当前为 2024-01-17 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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();



})();