Skip to content

Commit

Permalink
Теперь импорт чата в HTML файл & сделано скачиваниеmod/page/view.php
Browse files Browse the repository at this point in the history
  • Loading branch information
tankalxat34 committed Apr 22, 2023
1 parent 770610e commit 9881e3a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"matches": [ "*://lms.ranepa.ru/mod/resource/view.php?*", "*://lms-dpo.ranepa.ru/mod/resource/view.php?*" ],
"js": [ "scripts/mod/resource/view.js" ]
},
{
"matches": [ "*://lms.ranepa.ru/mod/page/view.php?*", "*://lms-dpo.ranepa.ru/mod/page/view.php?*" ],
"js": [ "scripts/mod/page/view.js" ]
},
{
"matches": [ "*://lms.ranepa.ru/user/preferences.php", "*://lms.ranepa.ru/user/preferences.php" ],
"js": [ "scripts/user/preferences/preferences.js" ]
Expand Down
4 changes: 4 additions & 0 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ try {
case "/user/preferences.php":
addSrcScript("scripts/user/preferences/preferences_front.js")
break;

case "/mod/page/view.php":
addSrcScript("scripts/mod/page/view/view_front.js")
break;

default:
break;
Expand Down
10 changes: 10 additions & 0 deletions scripts/mod/page/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
window.onload = () => {
let badge = document.createElement("span");
badge.innerHTML = `<a class="badge badge-info rounded mb-1"><i class="fa fa-download"></i> Скачать в HTML</a> `
badge.addEventListener("click", () => {
downloadFileFromText(`${document.querySelector(".page-header-headings > h1").textContent}.html`, document.querySelector(".no-overflow").innerHTML)
});
badge.style.cursor = "pointer";
badge.title = `Нажав на кнопку вы сможете скачать контент с этой страницы в виде HTML файла`
document.querySelector(".automatic-completion-conditions").append(badge);
}
Empty file added scripts/mod/page/view_front.js
Empty file.
7 changes: 1 addition & 6 deletions scripts/mod/quiz/attempt/attempt.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,7 @@ function addListenersToChat() {
})

document.querySelector("#helper-btn-chatgpt_export").addEventListener("click", () => {
let content = "<!-- Generated automatically using the LMS RANEPA HELPER extension (c) tankalxat34 -->\n";
for (let i = 0; i < ChatGPT.conversation.length; i ++) {
content += `\n\n## ${ChatGPT.conversation[i].role}\n\n`;
content += `${ChatGPT.conversation[i].content}`;
}
downloadFileFromText(`conversation ${new Date().toLocaleString()}.md`, content);
downloadFileFromText(`ChatGPT ${document.querySelector(".page-header-headings > h1").textContent} ${new Date().toLocaleString()}.html`, `<!-- Generated automatically using the LMS RANEPA HELPER extension (c) tankalxat34 -->\n\n<h3>${document.querySelector(".page-header-headings > h1").textContent}</h3>` + document.querySelector("#helper-chatgpt_response").innerHTML)
})

document.querySelector("#helper-chatgpt_div_input").addEventListener("keyup", (event) => {
Expand Down

0 comments on commit 9881e3a

Please sign in to comment.