| @@ -1,62 +1 @@ | ||
| 1 | -function insertAfter(e, t) { | |
| 2 | - t.parentNode.insertBefore(e, t.nextSibling) | |
| 3 | -} | |
| 4 | - | |
| 5 | -function getElementByXPath(e, t) { | |
| 6 | - if (!t) t = document; | |
| 7 | - if (t.evaluate) return t.evaluate(e, document, null, 9, null).singleNodeValue; | |
| 8 | - while (e.charAt(0) == "/") e = e.substr(1); | |
| 9 | - var n = t; | |
| 10 | - var r = e.split("/"); | |
| 11 | - for (var i = 0; i < r.length; i++) { | |
| 12 | - var a = r[i].split(/(\w*)\[(\d*)\]/gi).filter(function(e) { | |
| 13 | - return !(e == "" || e.match(/\s/gi)) | |
| 14 | - }, this); | |
| 15 | - var l = a[0]; | |
| 16 | - var o = a[1] ? a[1] - 1 : 0; | |
| 17 | - if (i < r.length - 1) n = n.getElementsByTagName(l)[o]; | |
| 18 | - else return n.getElementsByTagName(l)[o] | |
| 19 | - } | |
| 20 | -} | |
| 21 | -if (!Array.prototype.filter) { | |
| 22 | - Array.prototype.filter = function(e) { | |
| 23 | - var t = this.length >>> 0; | |
| 24 | - if (typeof e != "function") { | |
| 25 | - throw new TypeError | |
| 26 | - } | |
| 27 | - var n = []; | |
| 28 | - var r = arguments[1]; | |
| 29 | - for (var i = 0; i < t; i++) { | |
| 30 | - if (i in this) { | |
| 31 | - var a = this[i]; | |
| 32 | - if (e.call(r, a, i, this)) { | |
| 33 | - n.push(a) | |
| 34 | - } | |
| 35 | - } | |
| 36 | - } | |
| 37 | - return n | |
| 38 | - } | |
| 39 | -} | |
| 40 | - | |
| 41 | -function injectWidgetByXpath(e) { | |
| 42 | - var t = getElementByXPath(e); | |
| 43 | - if (t == null) { | |
| 44 | - t = document.getElementById("tbdefault") | |
| 45 | - } | |
| 46 | - innerInject(t) | |
| 47 | -} | |
| 48 | - | |
| 49 | -function injectWidgetByMarker(e) { | |
| 50 | - var t = document.getElementById(e); | |
| 51 | - innerInject(t.parentNode) | |
| 52 | -} | |
| 53 | - | |
| 54 | -function innerInject(e) { | |
| 55 | - var t = document.createElement("span"); | |
| 56 | - var n = document.createElement("script"); | |
| 57 | - var r = "if JS crashes here, the first innerHTML value should be enclosed with single quotes instead of double, go to the minified version and change it"; | |
| 58 | - t.innerHTML = "{{HTML}}"; | |
| 59 | - n.innerHTML = "{{SCRIPT}}"; | |
| 60 | - insertAfter(t, e); | |
| 61 | - insertAfter(n, t) | |
| 62 | -} | |
| 1 | +function insertAfter(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function getElementByXPath(e,t){if(!t)t=document;if(t.evaluate)return t.evaluate(e,document,null,9,null).singleNodeValue;while(e.charAt(0)=="/")e=e.substr(1);var n=t;var r=e.split("/");for(var i=0;i<r.length;i++){var a=r[i].split(/(\w*)\[(\d*)\]/gi).filter(function(e){return!(e==""||e.match(/\s/gi))},this);var l=a[0];var o=a[1]?a[1]-1:0;if(i<r.length-1)n=n.getElementsByTagName(l)[o];else return n.getElementsByTagName(l)[o]}}if(!Array.prototype.filter){Array.prototype.filter=function(e){var t=this.length>>>0;if(typeof e!="function"){throw new TypeError}var n=[];var r=arguments[1];for(var i=0;i<t;i++){if(i in this){var a=this[i];if(e.call(r,a,i,this)){n.push(a)}}}return n}}function injectWidgetByXpath(e){var t=getElementByXPath(e);if(t==null){t=document.getElementById("tbdefault")}innerInject(t)}function injectWidgetByMarker(e){var t=document.getElementById(e);innerInject(t.parentNode)}function innerInject(e){var t=document.createElement("span");var n=document.createElement("script");var r="if JS crashes here, the first innerHTML value should be enclosed with single quotes instead of double, go to the minified version and change it";t.innerHTML="{{HTML}}";n.innerHTML="{{SCRIPT}}";insertAfter(t,e);insertAfter(n,t)} | |