Skip to content

Instantly share code, notes, and snippets.

@jcchurch
Created January 7, 2015 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcchurch/7e6265ce1a77ab9ab604 to your computer and use it in GitHub Desktop.
Save jcchurch/7e6265ce1a77ab9ab604 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Set the editor mode
// @namespace
// @description Set the Plain Text Mode within Moddle
// @include http://courses.cs.westga.edu/*
// @version 0.1
// @grant none
// ==/UserScript==
//
// This script will change the default Plain Text editor format
// to a specified option rather than "HTML format".
//
// The current setting in this script is for Markdown format.
//
// 1: HTML format
// 2: Moodle auto-format
// 3: Plain text format
// 4: Markdown format
//
// Written 20150105
var desiredTextFormat = "4";
function setSelectedIndex(selectionBoxId, value) {
selectionBox = document.getElementById(selectionBoxId);
if (selectionBox != null) {
for (var i = 0; i < selectionBox.options.length; i++ ) {
if (selectionBox.options[i].value == value) {
selectionBox.options[i].selected = true;
return;
}
}
}
}
window.addEventListener("load", function(e) {
setSelectedIndex("menusummary_editorformat", desiredTextFormat);
setSelectedIndex("menuintroeditorformat", desiredTextFormat);
setSelectedIndex("menupageformat", desiredTextFormat);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment