2023/02/21
芯語
` } else { html = `
${m.title}
` } let node = document.createElement( “div” ) node.style.cssText = “width: 50%;float: left;” node.addEventListener(“click”, () => { $.ajax({ url: `https://twtpstat.zhentoo.com/extendstat2.ashx?artid=${artid}&extendids=${m.id}&position=1&type=2`, success: function (result) { location.href = m.url; } }); }) node.innerHTML = html; midiv.appendChild(node) midUrl.push(m.id); }) fixList.forEach((m, index) => { let html = “; if (index === 1) { html = `
${m.title}
` } else { html = `
${m.title}
` } let node = document.createElement( “div” ) node.style.cssText = “width: 50%;float: left;” node.addEventListener(“click”, () => { $.ajax({ url: `https://twtpstat.zhentoo.com/extendstat2.ashx?artid=${artid}&extendids=${m.id}&position=2&type=2`, success: function (result) { location.href = m.url; } }); }) node.innerHTML = html; fixdiv.appendChild(node) fixUrl.push(m.id); }) } }); function hasScrollbar() { return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight); } function closePop23() { document.querySelector(“#pop_2_3_fixed”).style.transform = “translateY(100vh)” } document.addEventListener(“scroll”, function () { var scope = (midiv.offsetHeight * (100 – 80)) / 100; //廣告欄可出線範圍大小 var cH = document.documentElement.clientHeight; //當前頁面可見區域高度 var tY = midiv.getBoundingClientRect().top; //廣告欄頂部到可見區域頂端的高度 var bY = midiv.getBoundingClientRect().bottom; //廣告欄底部到可見區域頂端的高度 // 需要考慮兩種可能 當tY小於-scope則代表不在窗口展示 當bY大於cH+scope則代表不在窗口展示 if (tY cH + scope) { } else if (ismid) { ismid = false; var extendids = []; midUrl.forEach(u => { extendids.push(u); }); if (extendids.length > 0) { $.ajax({ url: `https://twtpstat.zhentoo.com/extendstat2.ashx?artid=${artid}&extendids=${extendids.toString()}&position=1&type=1`, success: function (result) { } }); } } }); var clint = document.documentElement; var clintbox = document.querySelector( ‘.artcontent’ ) ? document.querySelector( ‘.artcontent’ ) : document.scrollingElement; //獲取視圖窗口的高度 var windowHeight = document.body.clientHeight; //綁定事件 window.addEventListener(‘scroll’, function () { let SH = parseInt(clint.scrollTop); let H = parseInt( clint.scrollHeight ); if ( SH >= (clintbox.scrollHeight + document.querySelector( ‘.artcontent’ ).offsetTop) * 2 / 3 ) { //此時滾動條滾動到底部 if (isshow23) { isshow23 = false; document.querySelector(“#pop_2_3_fixed”).style.transform = “translateY(0)” var extendids = []; fixUrl.forEach(u => { extendids.push(u); }) $.ajax({url: `https://twtpstat.zhentoo.com/extendstat2.ashx?artid=${artid}&extendids=${extendids.toString()}&position=2&type=1`, success: function (result) { }}); } } }); }