Skip to content

Instantly share code, notes, and snippets.

@dizys
Last active February 14, 2022 23:35
Show Gist options
  • Save dizys/93a3f3d58f90e4942a197fb30d0f077a to your computer and use it in GitHub Desktop.
Save dizys/93a3f3d58f90e4942a197fb30d0f077a to your computer and use it in GitHub Desktop.
Print mode for Brightspace Contents and Assignments
function setPrintMode(on) {
let hidden = on;
document
.querySelector(
"#d2l_body > header > nav > d2l-navigation > d2l-navigation-main-header"
)
.shadowRoot.querySelector("div").hidden = hidden;
document
.querySelector(
"#d2l_body > header > nav > d2l-navigation > d2l-navigation-main-footer"
)
.shadowRoot.querySelector("div").hidden = hidden;
document.querySelector("#z_g").hidden = hidden;
document.querySelector("#d2l_form > div > h2").hidden = hidden;
document.querySelector("#d2l_form > div > table").hidden = hidden;
document.querySelector("#d_content_r > d2l-floating-buttons").hidden = hidden;
}
setPrintMode(true);
window.print();
setPrintMode(false);
function setPrintMode(on) {
document.querySelector("div.navigation-container").style.display = on ? "none" : "block";
document.querySelector("#content-header").style.display = on ? "none" : "block";
let contentPanel = document.querySelector("#root-wrapper > div.main-wrapper > div.root > div.main > div.content-panel");
contentPanel.style.position = on ? "initial" : "absolute";
contentPanel.style.height = on ? "auto" : "";
contentPanel.style.left = on ? "0" : "";
contentPanel.style.width = on ? "100%" : "";
document.querySelector("#content-block").style['overflowY'] = on ? "visible" : "auto";
}
setPrintMode(true)
window.print()
setPrintMode(false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment