Greasy Fork

国家开放大学自动发帖

国家开放大学自动发帖能够设置帖子,帖子见自定义

// ==UserScript==
// @name         国家开放大学自动发帖
// @namespace    ouchn.cn
// @version      1.0
// @description  国家开放大学自动发帖能够设置帖子,帖子见自定义
// @author       zidognfatie
// @match        *://*.ouchn.cn/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    console.log('发帖助手');
    let setting = {
        subject: '好好学习天天向上', // 主题
        body: '好好学习天天向上,说了的话要做到' // 正文
    };
    let lhref = window.location.href;
    let flag = true;
    //刷课对象
    var type = 0;
    var dotime = 0;
    var Cla = {
        doForum: function () {
            if ($('#id_subject').length == 0)
                return;
            if (!$('#collapseAddForm').hasClass('show'))
                $('#collapseAddForm').addClass('show');
            $('#id_subject').val(setting.subject);
            if ($('iframe').length > 0) {
                window.setTimeout(function () {
                    $('iframe:eq(0)').contents().find('body').html(setting.body);
                }, 500);

            }
            window.setTimeout(function () {
                $('#id_submitbutton').click();
                alert('发帖成功');
            }, 1500);

        }

    };
    $(document).ready(function () {
        if (lhref.includes('/mod/forum/view.php')) {

            window.setTimeout(function () {
                  if ($('.alert p').text().includes('您的帖子已成功添加')
                || $('#id_submitbutton').length == 0
            ) {
                return;
            }
                Cla.doForum();
            }, 1500);

        }

    });
})();