var title = document.getElementsByClassName('bmenu')[0].innerText;
var code = document.getElementsByClassName('backcode')[0].innerText;
var data = title + '\n\n' + code;
saveFile(title + '.txt', data);
function saveFile(filename, data) {
var blob = new Blob([data], {type:'text/plain'});
var saveLink = document.createElement("a");
saveLink.download = filename;
saveLink.innerHTML = "Save file";
if (window.webkitURL != null) {
saveLink.href = window.webkitURL.createObjectURL(blob);
} else {
saveLink.href = window.URL.createObjectURL(blob);
saveLink.onclick = destroyClickedElement;
saveLink.style.display = "none";
document.body.appendChild(saveLink);
}
saveLink.click();
}
function destroyClickedElement(event) {
document.body.removeChild(event.target);
}