/*jslint indent: 2 */
/*global $: false, document: false, togglbutton: false*/
'use strict';

togglbutton.render('#tutorial-content [data-reactid="6"]:not(.toggl)', {}, function (elem) {
  var link, topic, project;

  // remove child nodes. Keep only textContent
  function cloneText(node) {
    var i, n, textNode = node.cloneNode(true)
    for (i=0, n=textNode.children.length; i<n; i++) {
      textNode.removeChild(textNode.children[i])
    }
    return textNode
  }

  topic = cloneText(elem).textContent.trim();
  project = elem.querySelector('[role="navigation"] span:first-child a').textContent.trim()

  link = togglbutton.createTimerLink({
    className: 'khanacademy',
    buttonType: 'minimal',
    description: topic,
    projectName: project
  });

  elem.style.position = 'relative';
  elem.appendChild(link);
});

@@ -330,16 +330,17 @@
 de(true)
+;
 %0A    for
@@ -346,14 +346,18 @@
 r (i
-=
+ = 
 0, n
-=
+ = 
 text
@@ -383,15 +383,20 @@
 h; i
-%3C
+ %3C 
 n; i
-++
+ += 1
 ) %7B%0A
@@ -443,16 +443,17 @@
 dren%5Bi%5D)
+;
 %0A    %7D%0A 
@@ -470,16 +470,17 @@
 textNode
+;
 %0A  %7D%0A%0A  
@@ -614,16 +614,17 @@
 t.trim()
+;
 %0A%0A  link

Fix linting errors