PageSourceSearch

https://worldofrenewables.com/wp-content/cache/min/1/wp-content/pl…/assets/js/post-views.js?ver=1790344130

js worldofrenewables.com collected 2026-10-02 10:35:01 UTC 1,762 bytes, 18 lines download raw bytes

1'use strict';(()=>{const STORAGE_KEY='sphere-post-views';let configs;function init(postID){configs=Sphere_PostViews;postID=postID||configs.postID||null;if(!window.fetch||!configs||!postID){return}
2if(configs.sampling){const rand=Math.floor(Math.random()*configs.samplingRate)+1;if(rand!==1){return}}
3if(isCrawler()){return}
4if(recentlyCounted(postID)){return}
5const params={method:'POST',headers:{'Content-type':'application/x-www-form-urlencoded'},body:['post_id='+postID,'action=update_views_ajax','token='+configs.token].join('&')};fetch(configs.ajaxUrl,params).then(resp=>resp.text()).then(data=>logViewCount(postID))}
6function recentlyCounted(id){if(!configs.repeatCountDelay){return!1}
7const repeatCountDelay=3600*parseFloat(configs.repeatCountDelay)*1000;const viewed=getStorage()||{};if(!viewed||!viewed.posts||(!id in viewed.posts)){return!1}
8const lastViewed=parseInt(viewed.posts[id]);if((Date.now()-lastViewed)<repeatCountDelay){return!0}
9return!1}
10function getStorage(){let viewed=localStorage.getItem(STORAGE_KEY);if(!viewed){return!1}
11try{viewed=JSON.parse(viewed);if(viewed.posts&&Object.keys(viewed.posts).length>10000){viewed={}}}catch(e){return!1}
12return viewed}
13function logViewCount(id){if(!configs.repeatCountDelay){return}
14const viewed=getStorage()||{};viewed.posts=viewed.posts||{};viewed.posts[id]=Date.now();localStorage.setItem(STORAGE_KEY,JSON.stringify(viewed))}
15function isCrawler(){if(navigator.webdriver){return!0}
16const isBot=/headless|bot|spider|crawl|google|baidu|bing|msn|teoma|slurp|yandex/i.test(navigator.userAgent);return isBot}
17document.readyState!=='loading'?init():document.addEventListener('DOMContentLoaded',()=>init());document.addEventListener('spc-alp-pageview',e=>{if(!e.detail.id){return}
18init(e.detail.id)})})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.