PluginProbe ʕ •ᴥ•ʔ
Post Views Counter / trunk
Post Views Counter vtrunk
1.7.13 1.7.12 1.7.11 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.2 1.3.2.1 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.7.10 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9
post-views-counter / js / frontend.js
post-views-counter / js Last commit date
admin-columns.js 5 months ago admin-dashboard.js 2 weeks ago admin-post.js 5 months ago admin-quick-edit.js 2 weeks ago admin-settings.js 2 weeks ago admin-theme.js 5 months ago admin-widgets.js 5 months ago block-editor.js 5 months ago counter.js 5 months ago frontend.js 2 weeks ago integration-gutenberg.js 5 months ago
frontend.js
2 lines
1 function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,o){if(t){if("string"==typeof t)return e(t,o);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,o):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=Array(e);o<e;o++)n[o]=t[o];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}window.PostViewsCounter={promise:null,args:{},init:function(t){this.args=t;var e={storage_type:"cookies",storage_data:this.readCookieData("pvc_visits".concat(!1!==t.multisite?"_".concat(parseInt(t.multisite,10)):""))};"rest_api"===t.mode?this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":t.nonce}):(e.action="pvc-check-post",e.pvc_nonce=t.nonce,e.id=t.postID,this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"}))},request:function(t,e,n,r){var a=this,c={method:n,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:r,body:this.prepareRequestData(e)};return fetch(t,c).then(function(t){if(!t.ok)throw Error(t.statusText);return t.json()}).then(function(t){try{"object"===o(t)&&null!==t?"success"in t&&!1===t.success?(console.log("PVC: Request error."),console.log(t.data)):(a.saveCookieData(t.storage),a.triggerEvent("pvcCheckPost",t)):(console.log("PVC: Invalid object."),console.log(t))}catch(e){console.log("PVC: Invalid JSON data."),console.log(e)}}).catch(function(t){console.log("PVC: Invalid response."),console.log(t)})},prepareRequestData:function(t){return Object.keys(t).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t[e]))}).join("&").replace(/%20/g,"+")},triggerEvent:function(t,e){var o=new CustomEvent(t,{bubbles:!0,detail:e});document.dispatchEvent(o)},getCookiePath:function(){var t="string"==typeof this.args.path?this.args.path.trim():"";if(!t||"/"===t)return"/";var e=t.replace(/\/{2,}/g,"/").replace(/^\/+|\/+$/g,"");return e?"/".concat(e,"/"):"/"},saveCookieData:function(e){var o=this;if(e&&Object.prototype.hasOwnProperty.call(e,"name")){var n=t(new Set(e.name.map(function(t){return t.replace(/\[\d+\]$/,"")}))),r="";"https:"===document.location.protocol&&(r=";secure"),n.forEach(function(t){document.cookie.split(";").forEach(function(e){if(e&&e.trim()){var n=e.split("=")[0];if(n){var a=n.trim();new RegExp("^".concat(t,"\\[(\\d+)\\]$")).test(a)&&(document.cookie="".concat(a,"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=").concat(o.getCookiePath(),";domain=").concat(o.args.domain).concat(r,";SameSite=Lax"))}}})});for(var a=0;a<e.name.length;a++){var c=new Date,i=parseInt(e.expiry[a],10),s=e.value[a];"string"!=typeof s&&(s=String(null!=s?s:"")),i?i*=1e3:i=c.getTime()+864e5,c.setTime(i),document.cookie="".concat(e.name[a],"=").concat(encodeURIComponent(s),";expires=").concat(c.toUTCString(),";path=").concat(this.getCookiePath(),";domain=").concat(this.args.domain).concat(r,";SameSite=Lax")}}},readCookieData:function(t){var e=[];document.cookie.split(";").forEach(function(o){if(o&&o.trim()){var n=o.split("="),r=n[0],a=n.slice(1).join("=");if(r){var c=r.trim(),i=new RegExp("^".concat(t,"\\[(\\d+)\\]$")),s=c.match(i);if(s){var u=a||"";try{u=decodeURIComponent(u)}catch(l){u=a||""}e.push({index:parseInt(s[1],10),value:u})}}}}),e.sort(function(t,e){return t.index-e.index});var n=e.map(function(t){return t.value}),r=n.join("");if(r)try{var a=JSON.parse(r);if(a&&"object"===o(a)&&1===a.version)return r}catch(c){}return n.join("a")}};var n=function(){return window.PostViewsCounter.init(pvcArgsFrontend)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n();
2