Last active
February 22, 2020 12:04
-
-
Save sorashi/3c133f743f24459bc6cf0a121b7113ef to your computer and use it in GitHub Desktop.
recodex user script for Tampermonkey/Greasemonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ReCodEx Task Markdown to Clipboard | |
// @description Adds a button to ReCodEx tasks, which allows you to copy the task markdown to clipboard | |
// @namespace http://sorashi.github.io/ | |
// @version 0.1 | |
// @author sorashi | |
// @include https://recodex.mff.cuni.cz/app/assignment/* | |
// @updateURL https://gist.github.com/sorashi/3c133f743f24459bc6cf0a121b7113ef/raw | |
// @downloadURL https://gist.github.com/sorashi/3c133f743f24459bc6cf0a121b7113ef/raw | |
// @require https://unpkg.com/turndown/dist/turndown.js | |
// @require http://code.jquery.com/jquery-3.4.1.min.js | |
// @require https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js | |
// @grant GM_setClipboard | |
// @run-at document-end | |
// ==/UserScript== | |
waitForKeyElements('.tab-pane.active', tab => { | |
'use strict'; | |
var panes = document.getElementById('localized-texts') | |
var button = document.createElement('button') | |
button.innerHTML = "Copy Markdown" | |
button.addEventListener('click', () => { | |
var turndownService = new TurndownService() | |
var content = tab.children()[0] | |
var markdown = turndownService.turndown(content) | |
GM_setClipboard(markdown) | |
}); | |
panes.prepend(button) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment