Last active
May 14, 2016 10:38
-
-
Save nervetattoo/3bf0380ca7023b1b36ed to your computer and use it in GitHub Desktop.
its-karakterer
This file contains 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 its-karakterpoeng | |
// @namespace http://your.homepage/ | |
// @version 0.8 | |
// @description enter something useful | |
// @author You | |
// @match http*://hfk.itslearning.com/* | |
// @grant unsafeWindow | |
// @run-at context-menu | |
// ==/UserScript== | |
var win = unsafeWindow; | |
var points = win.prompt('Hva er maks poeng på prøven?', 10); | |
function getPoint(percent) { | |
var dec = Number(percent.replace(',','.')); | |
return Math.round(dec * points) / 100; | |
} | |
var iframe = win.document.querySelector('iframe').contentDocument; | |
var tableRows = iframe.body.querySelectorAll('.nttinputtable tr'); | |
var tableHead = tableRows[0]; | |
var th = iframe.createElement('th'); | |
th.innerHTML = 'Maks: ' + points; | |
tableHead.appendChild(th); | |
tableRows = Array.prototype.slice.call(tableRows, 1); | |
Array.prototype.forEach.call(tableRows, function(row) { | |
var t = row.querySelectorAll('td'); | |
var html = getPoint(t[1].querySelector('input').value); | |
var td = iframe.createElement('td'); | |
td.appendChild(iframe.createTextNode(html)); | |
row.appendChild(td); | |
}); |
Author
nervetattoo
commented
Sep 27, 2015
•
- Installer tampermonkey
- Gå til tampermonkey => utilities => URL: Lim inn => import
- https://gist.github.com/nervetattoo/3bf0380ca7023b1b36ed/raw/893d5dd15e1e59db4cee71a511177416b6724815/its-karakterer.js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment