Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RensHam committed Oct 4, 2017
0 parents commit c600f53
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
43 changes: 43 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function cleanPage(e) {
let header = document.getElementsByTagName('header')[0];
header.style = 'display: none';
document.getElementById('restoreHeader').style = '';
let content = document.getElementById('ContentView').parentNode;
let childs = content.childNodes;
childs[childs.length - 1].style = 'display: none';
let quiz = document.getElementsByTagName('iframe')[0];
quiz.height = quiz.contentWindow.document.body.scrollHeight + 'px';
quiz.style = 'height: ' + quiz.height + ' !important';
quiz.scrolling = 'no';
document.body.style = '';
}

function toggleHeader(e) {
let header = document.getElementsByTagName('header')[0];
if (header.style.display === 'none') {
header.style = '';
document.getElementById('restoreHeader').style = 'display: none';
} else {
header.style = 'display: none';
document.getElementById('restoreHeader').style = '';
}
}

let listMenu = document.getElementsByTagName('header')[0].querySelector('div[role="list"]');
let button = document.createElement('div');
button.classList.add('d2l-navigation-s-item');
button.onclick = cleanPage;
button.innerText = 'Quiz layout';
listMenu.appendChild(button);

let toggleHeaderButttonInHeader = document.createElement('div');
toggleHeaderButttonInHeader.innerText = 'Hide menu';
toggleHeaderButttonInHeader.onclick = toggleHeader;
listMenu.appendChild(toggleHeaderButttonInHeader);

let toggleHeaderButtton = document.createElement('button');
toggleHeaderButtton.innerText = 'Show menu';
toggleHeaderButtton.onclick = toggleHeader;
toggleHeaderButtton.id = 'restoreHeader';
toggleHeaderButtton.style = 'display: none';
document.body.insertBefore(toggleHeaderButtton,document.body.firstChild);
Binary file added icons/border-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{

"description": "Add extra layout options to the Brightspace page of the TU Delft",
"manifest_version": 2,
"name": "Improve the TUDelft Brightspace page",
"version": "1.0",
"homepage_url": "https://github.com/RensHam/",

"icons": {
"48": "icons/border-48.png"
},

"content_scripts": [
{
"matches": ["*://brightspace.tudelft.nl/*"],
"js": ["background.js"]
}
]

}

0 comments on commit c600f53

Please sign in to comment.