1/* global chrome browser */ 2 3/** 4 * check if the current tab is a dokuwiki edit session and 5 * inject the toolbox script if yes 6 */ 7(function () { 8 // guards to make sure we only run on DokuWiki: 9 var gen = document.querySelector("meta[name='generator']"); 10 if (!gen || (gen.content.search(/DokuWiki/) === -1)) return; 11 var edi = document.querySelector("#wiki__text"); 12 if (!edi) return; 13 14 // inject the script 15 var script = document.createElement('script'); 16 script.setAttribute("type", "application/javascript"); 17 script.src = (chrome || browser).extension.getURL('script.js'); 18 script.onload = function () { 19 this.remove(); 20 }; 21 (document.head || document.documentElement).appendChild(script); 22})(); 23 24