Skip to content
Snippets Groups Projects
Commit 71697ebe authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Add new file

parent 19b39523
No related branches found
No related tags found
No related merge requests found
// ==UserScript==
// @name Bromcom VLE Tools
// @namespace http://radialbog9.uk/
// @version 2024-02-04
// @description Bromcom VLE dashboard widget
// @author Radialbog9
// @match https://vle.bromcomcloud.com/Home/Dashboard
// @downloadURL https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
// @updateURL https://git.rb9.xyz/TheJoeCoder/bromcom-vle-to-ics/-/raw/main/bvletools.user.js
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @require https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js
// @grant none
// ==/UserScript==
/*
<div class="grid-stack-item ui-draggable ui-resizable ui-resizable-autohide ui-resizable-disabled" id="gs_RB9Buttons" data-color="danger" data-gs-id="gs_RB9Buttons" data-gs-x="8" data-gs-y="2" data-gs-width="4" data-gs-height="2" data-gs-no-resize="yes">
<div class="panel panel-danger shadow grid-stack-item-content ui-draggable-handle">
<div class="panel-heading">
<table>
<tbody>
<tr class="tableheader">
<td><i style="font-size:35px; padding-right:5px; padding-left:5px" class="fa fa fa-wrench "></i></td>
<td>
<h3 class="panel-title">Toolkit</h3><h5 class="panelSubTitle">Utilities Toolkit</h5>
</td>
</tr>
<tr></tr>
</tbody>
</table>
</div>
<div id="content_RB9Buttons" style="display:block; width: 100%;padding:0px;" class="ifNoDataInWidget">
<span class="txtalignCenter"><a id="rb9ButtonGetTTWeek">Get Timetable (This Week)</a></span>
</div>
</div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90; display: none;"></div>
</div>
*/
(function() {
'use strict';
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) {month = '0' + month;}
if (day.length < 2) {day = '0' + day;}
return [year, month, day].join('-');
}
addEventListener("load", (e) => {
$("#widgetsDahsboard .grid-stack").append("\r\n<div class=\"grid-stack-item ui-draggable ui-resizable ui-resizable-autohide ui-resizable-disabled\" id=\"gs_RB9Buttons\" data-color=\"danger\" data-gs-id=\"gs_RB9Buttons\" data-gs-x=\"8\" data-gs-y=\"2\" data-gs-width=\"4\" data-gs-height=\"2\" data-gs-no-resize=\"yes\">\r\n <div class=\"panel panel-danger shadow grid-stack-item-content ui-draggable-handle\">\r\n <div class=\"panel-heading\">\r\n <table>\r\n <tbody>\r\n <tr class=\"tableheader\">\r\n <td><i style=\"font-size:35px; padding-right:5px; padding-left:5px\" class=\"fa fa fa-wrench \"><\/i><\/td>\r\n <td>\r\n <h3 class=\"panel-title\">Toolkit<\/h3><h5 class=\"panelSubTitle\">Utilities Toolkit<\/h5>\r\n <\/td>\r\n <\/tr>\r\n <tr><\/tr>\r\n <\/tbody>\r\n <\/table>\r\n <\/div>\r\n <div id=\"content_RB9Buttons\" style=\"display:block; width: 100%;padding:0px;\" class=\"ifNoDataInWidget\">\r\n<span class=\"txtalignCenter\"><a id=\"rb9ButtonGetTTWeek\">Get Timetable (This Week)<\/a><\/span>\r\n<\/div>\r\n <\/div><div class=\"ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se\" style=\"z-index: 90; display: none;\"><\/div>\r\n <\/div>");
$("#rb9ButtonGetTTWeek").on("click", () => {
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var lastSunday = new Date(today.setDate(today.getDate()-today.getDay()));
var nextSaturday = new Date(lastSunday).setDate(lastSunday.getDate() + 7);
var url = "https://vle.bromcomcloud.com/Timetable/GetTimeTable?WeekStartDate=" + formatDate(lastSunday) + "&weekEndDate=" + formatDate(nextSaturday) + "&type=1&id=0";
$.ajax({url: url, method: "POST", dataType: "json"})
.done((data) => {
var data_str = JSON.stringify(data);
console.log(data_str);
navigator.clipboard.writeText(data_str);
alert("Copied to Clipboard.");
});
});
});
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment