.brdCmb, h1.pTtl { display: none !important; } .ptc-post-block { display: block; width: 100%; background: linear-gradient(rgb(45,45,48, 0.7), rgb(45, 45, 48)) !important; color: #F9F9F9 !important; font-size: 14px; padding: 20px 10px 10px 10px; } .user-post { width: 100%; font-size: 14px; } .user-post p { padding: 5px; margin: 0 auto; word-wrap: break-word; opacity: 0.9; } .user-post h1 { margin: 0 auto; opacity: 0.9; } .user-post img { display: inline-block; opacity: 0.8; margin: 2px; /*max-height: 250px; */ width: 100%; } .user-post a { color: white; padding-left: 5px; vertical-align: super; padding: 5px; border-radius: 5px; opacity: 1; } .user-post span, .user-post small { display: inline-block; color: white; padding-left: 10px; opacity: 0.6; font-size: 16px; vertical-align: super; } .ptc-editor { width: 100%; min-height: 200px; resize: vertical; background: linear-gradient(rgb(61, 56, 50), rgb(41, 36, 30)) !important; color: #F9F9F9 !important; font-size: 16px; outline: none !important; padding-top: 50px !important; padding-left: 10px !important; } .ptc-controls { width: 100%; margin-bottom: 50px; } .ptc-controls .comment-title { position: relative; top: 50px; left: 5px; font-size: 12px; opacity: 0.8; } .ptc-controls input[type=file] { width: 100%; color: white !important; display: none; } .ptc-controls label { display: inline-block; font-size: 12px; vertical-align: super; } .ptc-controls label img { position: relative; top: 8px; width: 24px; height: 24px; border-radius: 20px; } .ptc-images img { display: inline-block; width: 150px; margin: 5px; } .ptc-controls button { display: inline-block; float: right; background: linear-gradient(rgb(61, 56, 50), rgb(41, 36, 30)) !important; color: white; outline: none; padding: 0 5px 0 5px; margin: 5px; font-size: 12px; } .ptc-comment-block { display: block; width: 100%; background: linear-gradient(rgb(45,45,48, 0.7), rgb(45, 45, 48)) !important; color: #F9F9F9 !important; font-size: 14px; padding: 20px 10px 10px 10px; } .user-info img { display: block; width: 128px; height: 128px; margin: 0 auto; } .user-info { text-align: center; display: block; margin: 0 auto; } .user-info p { display: block; margin: 0 auto; opacity: 0.9; } .user-info small { display: inline-block; /*background: #b33e0c;*/ padding: 0 10px 0 10px; opacity: 0.7; border-radius: 20px; color: white; } .user-message { width: 100%; font-size: 18px; } .user-message p { text-align: justify; padding: 5px; margin: 0 auto; opacity: 0.9; } .user-info a { display: block; text-decoration: underline; color: white; padding: 5px; margin: 0 auto; } .user-message img { background: white; opacity: 0.7; } .user-message a { word-wrap: break-word; font-size: 12px; } .user-message small { color: white; opacity: 0.6; } .ptc-comment-block button { width: 100%; padding: 0 10px 0 10px; color: white; background: transparent; opacity: 0.8; } .ptc-reply-snippet { color: black; background: white; opacity: 0.7; display: block; width: 100%; padding: 10px; max-height: 200px; overflow-y: auto; overflow-x: hidden; margin-bottom: 10px; cursor: pointer; } .ptc-reply-snippet img { max-height: 150px; } .ptc-reply-snippet a { color: black; word-wrap: break-word; } .ptc-reply-snippet p { margin: 0 auto; } .ptc-small-banner { background: rgba(0,0,0,0.3); height: 110px !important; margin: 10px; } .ptc-small-banner img { display: inline-block; height: 110px !important; width: 100% !important; object-fit: cover; padding: 5px; } .ptc-small-banner a { display: inline-block; margin: -10px 0 -10px 0; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: underline; color: white; opacity: 0.8; } .ptc-small-banner small { display: inline-block; margin: -3px 0 0 0; line-height: 15px; width: 100%; } .column { float: left; width: 33.33%; height: 110px !important; } .columnB { float: left; width: 60.00%; max-height: 110px !important; padding: 10px; overflow: hidden; text-align: justify; } .columnB small { height: 60px; overflow: hidden; } More from author No Comments _Enter your comment... 🖼️ Add Image Comment Related Posts let id = ''; let comment_id = ''; let url = window.location.href; let username = ''; let author_username = ''; let this_category = ''; let userpic = ''; let userRank = ''; let reply_to = 'none'; let post_data_r = ''; // all feeds data const ptcred = 'ptc_credentials'; let rank_names = { "10": "Beginner", "30": "Trainee", "60": "Amateur", "120": "Hustler", "240": "Hotshot", "480": "Virtuoso", "960": "Expert", "1000": "Veteran", "1050": "Semi-Pro", "2000": "Professional", "2050": "Master", "2100": "Champ", "2200": "Superstar", "2500": "Hero", "3000": "Legend", "4000": "Immortal" }; // STARTUP if(url.includes('&m=1')) url = url.replace('&m=1', ''); if(url.includes('?') && url.includes('#')) { // means it contains comment id comment_id = url.split('#')[1]; // .com/?post_id#commentid id = url.split('?')[1].replace('#' + comment_id, ''); } else if(url.includes('?')) id = url.split('?')[1]; else q('.ptc-post-block').innerHTML = '<h1>Invalid Url Request.</h1>'; // CHECK if user is online or not if(localStorage.getItem(ptcred)) { let temp_data = localStorage.getItem(ptcred); temp_data = JSON.parse(temp_data); username = temp_data.username; userpic = temp_data.img; delete temp_data; } else q('.ptc-controls').style.display = 'none'; // Get the rank of user and information of the post getRank(successRank); getPost(successGetPost); window.addEventListener('load', function() { getPost(successRelatedPost); getComments(buildComments); }, false); function successGetPost(data) { data = JSON.parse(data); post_data_r = data[id]; this_category = data[id].category; if (data[id]) { let post_data = data[id].posts; let user_data = data[id].user; author_username = user_data.username; q('.user-post h1').innerHTML = post_data.title; document.title = post_data.title; q('.user-post p').innerHTML = post_data.description.replaceAll('\n', '<br>').replace(/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/g, (x) => '<a target="_blank" href="https://storehaccounts.blogspot.com/p/link-terminal.html#' + btoa(x) + '">' + new URL(x).pathname + '...</a>'); q('.user-post span').innerText = moment(parseInt(id)).fromNow(); q('.user-post img').setAttribute('data-src', user_data.img); q('.user-post img').setAttribute('class', 'lazy'); q('.ptc-controls img').setAttribute('data-src', userpic); q('.ptc-controls img').setAttribute('class', 'lazy'); q('.user-post a').innerHTML = user_data.username + ' <div style="display: inline-block;" id="stats-rank"></div>'; q('.user-post a').href = 'https://storehaccounts.blogspot.com/p/your-account-page.html?' + data[id].user.username; for (i = 0; i < post_data.images.length; i++) { let img = document.createElement('img'); img.src = (post_data.images[i].includes('imgur.com') ? post_data.images[i] : 'https://i.imgur.com/ugPSMSdm.png'); q('.user-post').appendChild(img); } processUserRank(user_data.username); } else q('.ptc-post-block').innerHTML = '<h1>Invalid Url Request.</h1>'; delete data; } function successRelatedPost(data) { // Get all posts with the same category randomly data = JSON.parse(data); let keys = Object.keys(data); let arrOfSameCategory = []; let relatedCategory = []; let recentAuthorPost = []; for(i=0; i < keys.length; i++) { if(data[keys[i]].category == this_category && id != keys[i]) arrOfSameCategory.push(keys[i]); if(data[keys[i]].user.username == author_username && id != keys[i]) recentAuthorPost.push(keys[i]); } if(arrOfSameCategory.length > 0) { let numOfRelated = (arrOfSameCategory.length > 5 ? 5 : arrOfSameCategory.length); for(let i=0; i<numOfRelated; i++) { let random = genRandomNum(arrOfSameCategory.length); if(!relatedCategory.includes(arrOfSameCategory[random])) relatedCategory.push(arrOfSameCategory[random]); else i--; delete random; } delete arrOfSameCategory; } for(let i=0; i<relatedCategory.length; i++) { let post_data = data[relatedCategory[i]].posts; let childiv = document.createElement('div'); let imgThumb = post_data.images[0]; imgThumb = imgThumb.split('.'); imgThumb[2] += 'm'; imgThumb = imgThumb.join('.'); childiv.innerHTML = "<div class='ptc-small-banner'> <div class='column'> <img class='lazy' data-src='" + imgThumb +"'/> </div> <div class='columnB'> <a href='" + 'https://storehaccounts.blogspot.com/p/ptc-post-official.html?' + relatedCategory[i] + "'>" + post_data.title + " </a> <small>" + post_data.description + "</small> </div> </div>"; document.querySelector('.related-block').appendChild(childiv); } let numofauthorpost = (recentAuthorPost.length > 3 ? 3 : recentAuthorPost.length); for(let i=recentAuthorPost.length-1, o=0; o<numofauthorpost; i--, o++) { let author_data = data[recentAuthorPost[i]].posts; let temp_div = document.createElement('div'); let imgThumb = author_data.images[0]; imgThumb = imgThumb.split('.'); imgThumb[2] += 'm'; imgThumb = imgThumb.join('.'); temp_div.innerHTML = "<div class='ptc-small-banner'> <div class='column'> <img src='" + imgThumb +"'/> </div> <div class='columnB'> <a href='" + 'https://storehaccounts.blogspot.com/p/ptc-post-official.html?' + recentAuthorPost[i] + "'>" + author_data.title + " </a> <small>" + author_data.description + "</small> </div> </div>"; document.querySelector('.more-from-author').appendChild(temp_div); delete author_data; delete temp_div; } delete relatedCategory; document.querySelector('.ptc-post-block').innerHTML += '<a class="button ln" href="https://storehaccounts.blogspot.com/p/ptc-official-post-creator.html">Add More Posts</a> <a class="button ln" href="https://storehaccounts.blogspot.com/p/battle-cats-gamer-community.html">Back to Community</a>'; } function buildComments(data) { let post_data = JSON.parse(data)[id]; if(post_data) { let comment_keys = Object.keys(post_data); for(i=0; i < comment_keys.length; i++) { q('.comment-count').innerText = comment_keys.length + ' Comments'; q('.user-post small').innerText = comment_keys.length + ' comments'; let images_url = ''; for(j=0; j<post_data[comment_keys[i]].images.length; j++) images_url += "<img class='lazy' data-src='" + post_data[comment_keys[i]].images[j] +"'/>"; let commDiv = document.createElement('div'); commDiv.innerHTML += "<div id='" + comment_keys[i] + "' class='ptc-comment-block'> <span>#" + (i+1) + "</span> <div class='user-info'> <img src='" + post_data[comment_keys[i]].userpic + "'/> <a href='https://storehaccounts.blogspot.com/p/your-account-page.html?" + post_data[comment_keys[i]].username + "' target='_blank'>" + (post_data[comment_keys[i]].username == author_username ? '*author* ' + post_data[comment_keys[i]].username : post_data[comment_keys[i]].username) + "</a> <small>" + processRank(post_data[comment_keys[i]].username) + "</small></div>" + (post_data[comment_keys[i]].reply_to != 'none' ? '<div onclick="scrollToTargetAdjusted(' + post_data[comment_keys[i]].reply_to + ')" class="ptc-reply-snippet"><b>Replied to:</b><br>' + document.getElementById(post_data[comment_keys[i]].reply_to).getElementsByClassName('user-message')[0].innerHTML + '</div>' : '') + "<div class='user-message'><p>" + post_data[comment_keys[i]].msg.replaceAll('\n', '<br>').replace(/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/g, (x) => '<a target="_blank" href=' + x + '>' + x + '...</a>') + "<small><br>" + moment(parseInt(comment_keys[i])).fromNow() + "</small></p>" +images_url + "</div><button onclick='insertAfter(this)'>REPLY</button></div>"; q('.comment-container').appendChild(commDiv); } delete comment_keys; delete post_data; if(comment_id) { window.scrollTo(0, document.body.scrollHeight); setTimeout(() => {scrollToTargetAdjusted(comment_id);}, 1000); } } } function readyComment() { // check all requirements q('.ptc-controls').style.opacity = '0.7'; q('.ptc-controls').style.pointerEvents = 'none'; let msg = q('#comment-editor').value; let notifyCorruptedImg = false; let imgs = q('#comm_form_attached_images').childNodes; let imgarr = []; for (i = 0; i < imgs.length; i++) { if(imgs[i].src.includes('i.ibb')) imgarr.push(imgs[i].src); else { notifyCorruptedImg = true; q('#comm_form_attached_images').innerHTML = ''; window.alert('You have uploaded image that is corrupted. Please re-upload again.'); break; } } if (msg.length > 0 && !notifyCorruptedImg) { let this_comment_identification = new Date().getTime(); let comment_data = { [id]: { [this_comment_identification]: { "username": username, "userpic": userpic, "msg": msg, "images": imgarr, "reply_to": reply_to } } } let addComment = { [id]: { "comments": { [this_comment_identification]: "1" } } } patch('https://jsonbin.org/ptcreborn/ptc_feeds', addComment, null); patch('https://jsonbin.org/ptcreborn/ptc_comments', comment_data, null); //add notification to the respective owner.. if (username != author_username) { let pts_data = { [author_username]: { "points": { [new Date().getTime()]: "3" } } } patch('https://jsonbin.org/ptcreborn/ptc_user_ranks', pts_data, null); } if (reply_to != 'none') { // means replying to a comment author_username = document.getElementById(reply_to).querySelector('a').innerText.replace('*author* ', ''); console.log(author_username); if (username != author_username) { // means replying another user comment let notif_data = { [author_username]: { [new Date().getTime()]: { "username": username, "action": (reply_to == 'none' ? 'commented on your post "' + document.title + '"' : "replied to your comment"), "post_url": id + '#' + this_comment_identification } } } patch('https://jsonbin.org/ptcreborn/ptc_notifications', notif_data, null); } } else if(username != author_username) { // means commenting to the post itself as long as it is not your post let notif_data = { [author_username]: { [new Date().getTime()]: { "username": username, "action": (reply_to == 'none' ? 'commented on your post "' + document.title + '"' : "replied to your comment"), "post_url": id + '#' + this_comment_identification } } } patch('https://jsonbin.org/ptcreborn/ptc_notifications', notif_data, null); } successComment(this_comment_identification); } else { q('.ptc-controls').style.opacity = '1'; q('.ptc-controls').style.pointerEvents = 'auto'; window.alert('You need to type something and make sure images are not corrupted!'); } } function patch(url, data, callback) { let req = new XMLHttpRequest(); req.onload = () => { if (req.readyState == 4) if (req.status == 200) if (callback != null) callback(req.response); } req.onerror = (err) => { window.alert('Error encountered! ' + err); q('.ptc-controls').style.opacity = '1'; q('.ptc-controls').style.pointerEvents = 'auto'; } req.open('PATCH', url, false); req.setRequestHeader('Content-Type', 'application/json'); req.setRequestHeader('Authorization', 'token 44489997-ed40-4f52-92a9-dfe6fe8ad5db'); req.send(JSON.stringify(data)); } function successComment(commid) { let new_url = 'https://storehaccounts.blogspot.com/p/ptc-post-official.html?' + id + '#' + commid; if(new_url.includes('&m=1')) new_url = new_url.replace('&m=1', ''); setTimeout(function() { window.location.href = new_url; window.location.reload(); }, 1000); } function processUserRank(username) { let data = JSON.parse(userRank); let rank = '(Noob) 0 Pts.'; let key = Object.keys(data[username].points); if(data[username] && data[username].points) { let rkey = Object.keys(rank_names); let total = 0; for(let i=0; i<key.length; i++) total += parseInt(data[username].points[key[i]]); for(let i=0; i<rkey.length; i++) if(total <= parseInt(rkey[i])) { rank = '(' + (i == 0 ? rank_names[rkey[i]] : rank_names[rkey[i-1]]) + ') ' + total + ' Pts.'; break; } delete key; delete rkey; } document.querySelector('#stats-rank').innerText = rank; delete data; } function processRank(username) { let data = JSON.parse(userRank); let rank = '(Noob) 0 Pts.'; if(data[username] && data[username].points) { let key = Object.keys(data[username].points); let rkey = Object.keys(rank_names); let total = 0; for(let i=0; i<key.length; i++) total += parseInt(data[username].points[key[i]]); for(let i=0; i<rkey.length; i++) if(total <= parseInt(rkey[i])) { rank = '(' + (i == 0 ? rank_names[rkey[i]] : rank_names[rkey[i-1]]) + ') ' + total + ' Pts.'; break; } delete key; delete rkey; } delete data; return rank; } function successRank(data) { userRank = data; delete data; } function getPost(callback) { let req = new XMLHttpRequest(); req.onload = () => { if (req.readyState == 4) if (req.status == 200) if(callback) callback(req.response); } req.onerror = (err) => { window.alert('Error encountered! ' + err); } req.open('GET', 'https://jsonbin.org/ptcreborn/ptc_feeds', false); req.setRequestHeader('Content-Type', 'application/json'); req.setRequestHeader('Authorization', 'token 44489997-ed40-4f52-92a9-dfe6fe8ad5db'); req.send(); } const file = document.getElementById("comm_imgupload1") file.addEventListener("change", ev => { document.querySelector('#uploadImg').style.pointerEvents = 'none'; document.querySelector('#uploadImg').style.opacity = '0.7'; document.querySelector('#post_btn').style.pointerEvents = 'none'; document.querySelector('#post_btn').style.opacity = '0.7'; if (ev.target.files.length == 0) { document.querySelector('#uploadImg').style.pointerEvents = 'auto'; document.querySelector('#uploadImg').style.opacity = '1'; document.querySelector('#post_btn').style.pointerEvents = 'auto'; document.querySelector('#post_btn').style.opacity = '1'; } const formdata = new FormData() for (i = 0; i < ev.target.files.length; i++) { formdata.append("image", ev.target.files[i]) fetch("https://api.imgbb.com/1/upload?key=07f1351d4e674784012d92ae6e03b49d", { method: "post", body: formdata }).then(data => data.json()).then(data => { document.querySelector('#uploadImg').style.pointerEvents = 'auto'; document.querySelector('#uploadImg').style.opacity = '1'; document.querySelector('#post_btn').style.pointerEvents = 'auto'; document.querySelector('#post_btn').style.opacity = '1'; let img = document.createElement('img'); img.src = data.data.url; img.setAttribute('style', 'display: inline-block; margin: 5px; width: 150px !important'); document.querySelector('#comm_form_attached_images').appendChild(img); }) } }); function scrollToTargetAdjusted(id){ var element = document.getElementById(id).querySelector('p'); var headerOffset = 150; var elementPosition = element.getBoundingClientRect().top; var offsetPosition = elementPosition + window.pageYOffset - headerOffset; window.scrollTo({ top: offsetPosition, behavior: "smooth" }); } function genRandomNum(maxSize) { return Math.floor(Math.random() * maxSize); } function q(id) { return document.querySelector(id); } function getComments(callback) { let req = new XMLHttpRequest(); req.onload = () => { if (req.readyState == 4) if (req.status == 200) if(callback) callback(req.response); } req.onerror = (err) => { window.alert('Error encountered! ' + err); } req.open('GET', 'https://jsonbin.org/ptcreborn/ptc_comments', false); req.setRequestHeader('Content-Type', 'application/json'); req.setRequestHeader('Authorization', 'token 44489997-ed40-4f52-92a9-dfe6fe8ad5db'); req.send(); } function getRank(callback) { let req = new XMLHttpRequest(); req.onload = () => { if (req.readyState == 4) if (req.status == 200) if(callback) callback(req.response); } req.onerror = (err) => { window.alert('Error encountered! ' + err); } req.open('GET', 'https://jsonbin.org/ptcreborn/ptc_user_ranks', false); req.setRequestHeader('Content-Type', 'application/json'); req.setRequestHeader('Authorization', 'token 44489997-ed40-4f52-92a9-dfe6fe8ad5db'); req.send(); } function insertAfter(referenceNode, newNode) { reply_to = referenceNode.parentNode.id; referenceNode.parentNode.insertBefore(q('.ptc-controls'), referenceNode.nextSibling); }