2 function deparam(query) {
5 var search = /([^&=]+)=?([^&]*)/g;
7 var decode = function decode(s) {
8 return decodeURIComponent(s.replace(plus, ' '));
11 while (match = search.exec(query)) {
12 params[decode(match[1])] = decode(match[2]);
19 for (var name in obj) {
20 if (obj.hasOwnProperty(name) && obj[name]) {
21 parts.push(encodeURIComponent(name) + "=" + encodeURIComponent(obj[name]));
24 return parts.join('&');
27 let script = document.currentScript;
30 for (let i = 0; i < script.attributes.length; i++) {
31 let attribute = script.attributes.item(i);
32 attrs[attribute.name.replace(/^data-/, '')] = attribute.value;
35 let canonicalLink = document.querySelector("link[rel='canonical']");
36 attrs.url = canonicalLink ? canonicalLink.href : location.origin + location.pathname + location.search;
37 attrs.origin = location.origin;
38 attrs.pathname = location.pathname.length < 2 ? 'index' : location.pathname.substr(1).replace(/\.\w+$/, '');
39 attrs.title = document.title;
40 let descriptionMeta = document.querySelector("meta[name='description']");
41 attrs.description = descriptionMeta ? descriptionMeta.content : '';
42 let ogtitleMeta = document.querySelector("meta[property='og:title'],meta[name='og:title']");
43 attrs['og:title'] = ogtitleMeta ? ogtitleMeta.content : '';
44 document.head.insertAdjacentHTML('afterbegin', "<style>.Gissues{position:relative;box-sizing:border-box;width:100%;margin-left:auto;margin-right:auto;}.Gissues-frame{position:absolute;left:0;right:0;width:1px;min-width:100%;max-width:100%;height:100%;border:0;}</style>");
45 let Origin = "https://cleve.gitee.io/gissues";
46 let url = Origin + "/Gissues.html";
47 script.insertAdjacentHTML('afterend', "<div class='Gissues'><iframe class='Gissues-frame' title='Comments' scrolling='no' src='" + url + "?" + (0, param)(attrs) + "'></iframe></div>");
48 let container = script.nextElementSibling;
49 script.parentElement.removeChild(script);
50 addEventListener('message', function (event) {
51 if (event.origin !== Origin) {
55 let data = event.data;
57 if (data && data.type === 'resize' && data.height) {
58 container.style.height = data.height + "px";