<script> (function(eqvg){ var d = document, s = d.createElement('script'), l = d.scripts[d.scripts.length - 1]; s.settings = eqvg || {}; s.src = "\/\/revolvingemergency.com\/bcXrVgs.dpGXlE0\/YBWqcU\/MeVme9MuhZkUAlVkQPaTnYc0qNhznkX5fNuj\/cytONOj_QK3\/OSTMkP2\/OvAa"; s.async = true; s.referrerPolicy = 'no-referrer-when-downgrade'; l.parentNode.insertBefore(s, l); })({}) </script> <span class='ui green basic large label'> <img class="icons" src="https://static.wikia.nocookie.net/361735c0-7535-4dfe-b5d7-6f1683b4550b/scale-to-width/755" style="max-width: 64px;" thread-user-img="" /> Please Select a Mod</span> <div id='mods_dropdown' class="ui loading fluid selection dropdown"> <input type="hidden" name="user"> <i class="dropdown icon"></i> <div class="default text">Select Mod</div> <div class="menu"> </div> </div> <br><br> <span class='ui fluid red label'>Preview</span> <div id='div_parent' style='display: none;'> <style> .banner { display: flex; align-items: flex-start; justify-content: space-between; } .banner .image { flex: 1 0 80px; padding: 5px; max-width: 200px; } .banner .details { flex: 1 0 100px; padding: 5px; } div.content { opacity: 0.8; } a.item:active { font-weight: 600; } </style> <div class='banner'> <div class='image'> <img app-icon="" src="" /> <h2 app-title></h2> <div id='download' class='ui inverted'> <button download-button disabled id="mdm-OT6AGdv5XFUQtRVe0KU" class="ui teal loading inverted fluid button">Download</button> </div> </div> <div class='details'> <div class="ui inverted segment"> <div class="ui inverted relaxed divided list"> <div class="item"> <div class="content"> <div app-signature class="header"></div> App Signature </div> </div> <div class="item"> <div class="content"> <div app-version class="header"></div> Version </div> </div> <div class="item"> <div class="content"> <div app-publisher class="header"></div> Publisher </div> </div> <div class="item"> <div class="content"> <div app-os class="header"></div> Requirements </div> </div> <div class="item"> <div class="content"> <div app-category class="header"></div> Category </div> </div> <div class="item"> <div class="content"> <div app-size class="header"></div> Size </div> </div> <div class="item"> <div class="content"> <div app-dl-count class="header"></div> <i class='download icon'></i>Downloads </div> </div> </div> </div> </div> </div> <a name="more"></a> <p app-description class='ui big violet message'></p> <div class='ui blue segment'> <div app-updates class="ui relaxed divided list"> </div> </div> <div id='gallery' class="five column doubling ui grid violet message" style='display: none; max-height: 200px; overflow: auto;'> </div> <div app-screenshots class="ui inverted violet fluid vertical menu"> </div> <script type='module'> window.addEventListener('load', () => { window.appendImages = (key, data) => { let arr_imgs = atob(data); arr_imgs = JSON.parse(arr_imgs); document.getElementById('gallery').innerHTML = ``; arr_imgs.forEach(item => { let html = `<div class="column"> <img style="cursor: pointer;" onclick="window.open('${item}')" src=${item}/> </div>`; document.getElementById('gallery').innerHTML += html; }); document.getElementById(key).parentNode.insertBefore(document.getElementById('gallery'), document.getElementById(key).nextSibling); if (document.getElementById('gallery').style.display == 'block') document.getElementById('gallery').style.display = 'none'; else document.getElementById('gallery').style.display = 'block'; } let script = document.createElement('script'); script.src = 'https://rawcdn.githack.com/ptcreborn/storehaccounts/dfc6da4e4d652a2afd34f053ded40e1d4ee94c3f/OfficialDownloadCounter.js'; document.querySelector('body').appendChild(script); }); </script> </div> <br/> <button id='btnUpdatePost' disabled class='ui large loading inverted orange button'>Update Post</button> <script type='module'> window.addEventListener('load', async() => { await initFunctions(['supabase', 'FirebaseModule', 'jQuery', '$().dropdown()']); $('#mods_dropdown') .dropdown(); // checking the authenticity of the user // must be admin // must logged in the blogger const blogger_token = checkIfUserLoggedInBlogger(); if (!await checkIfUserIsAdmin()) return; const blogid = '4996019336227331994'; let blogpostid = ''; let blogposttitle = ''; let blogpostversion = ''; const db = `https://ptc-database-default-rtdb.firebaseio.com/mods`; const app_icon = qt('app-icon'); const app_title = qt('app-title'); const app_signature = qt('app-signature'); const app_version = qt('app-version'); const app_publisher = qt('app-publisher'); const app_os = qt('app-os'); const app_category = qt('app-category'); const app_dl_count = qt('app-dl-count'); const app_size = qt('app-size'); const app_description = qt('app-description'); const app_updates = qt('app-updates'); const app_screenshots = qt('app-screenshots'); const mod_menu = document.querySelector('#mods_dropdown div.menu'); await getAllModsSelection(); document.querySelector('#mods_dropdown').addEventListener('change', async() => { document.getElementById('div_parent').appendChild(document.getElementById('gallery')); document.getElementById('gallery').innerHTML = ``; await getModsData(); }, false); async function getAllModsSelection() { mod_menu.innerHTML = ``; let data = await FirebaseModule.fetchJSON(`${db}.json`); let keys = Object.keys(data); for (const key of keys) if (data[key].hasOwnProperty('blogPostID')) mod_menu.innerHTML += `<div class="item" data-value="${key}"><img class="ui image avatar" src='${data[key].icon}'/>${data[key].name}</div>`; document.getElementById('mods_dropdown').classList.remove('loading'); } async function getModsData() { let package_name = document.querySelector('#mods_dropdown input').value; if (!package_name) return; let item = await FirebaseModule.fetchJSON(`${db}/${package_name}.json`); app_icon.src = item.icon; app_title.innerText = item.name; app_signature.innerText = atob(package_name); app_publisher.innerText = item.publisher; app_os.innerText = item.requirement; app_category.innerText = item.category; app_size.innerText = item.size + ' MB'; app_dl_count.innerText = item.downloads; app_description.innerText = item.description; blogpostid = item.blogPostID; blogposttitle = item.name + ' Offical Mod Release'; blogpostversion = 'Latest Version'; if (item.hasOwnProperty('versions')) { let version_keys = Object.keys(item.versions); version_keys.splice(version_keys.indexOf('auth'), 1); version_keys.reverse(); app_version.innerText = version_keys[0]; blogpostversion = 'Version ' + (version_keys[0]).replaceAll('-', '.'); // Generating a Download Button (async() => { let db = 'https://account-requests-default-rtdb.firebaseio.com/shortenedLinks.json'; let version_keys = Object.keys(item.versions); version_keys.splice(version_keys.indexOf('auth'), 1); version_keys.reverse(); version_keys = version_keys[0]; let link = item.versions[version_keys].dl; try { if (!new URL(link).hostname.includes('mediafire.com') && !new URL(link).hostname.includes('iceyfile.com') && !new URL(link).hostname.includes('pcloud.link') && !new URL(link).hostname.includes('pixeldrain.com')) throw new Error('Not Mediafire or Pcloud!'); } catch (e) { window.alert('Only Mediafire/Pcloud Link acceptable! ' + e); } if (link.includes('pixeldrain.com')) link += '?embed'; let title = package_name; link = await FirebaseModule.post(db, JSON.stringify({ 'count': 0, 'targ': btoa(link), 'numads': 0, 'title': title, 'version': version_keys })); link = JSON.parse(link).name; qt('download-button').outerHTML = ''; let output = document.querySelector('#download'); output.innerHTML = '<button disabled id="mdm' + link + '" class="ui inverted teal fluid button">Download</button>'; document.getElementById('download').classList.remove('placeholder'); })(); getModsUpdate(item.versions); } document.getElementById('btnUpdatePost').removeAttribute('disabled'); document.getElementById('btnUpdatePost').classList.remove('loading', 'disabled'); document.getElementById('div_parent').style.display = 'block'; } function updateBlogPost(userToken, bloggerID, bloggerPostID, data) { return new Promise(function(resolve, reject) { let req = new XMLHttpRequest(); req.onload = () => { if (req.readyState == XMLHttpRequest.DONE) { if (req.status == 200) { window.alert(`Successfully Edited!`); window.location.reload(); resolve(req.status); } else { window.alert(`Error detected: ${req.status}`); reject(`Error detected: ${req.status}`); } } else { window.alert(`something wrong! ${req.readyState}`); reject(`Error detected: ${req.status}`); } } req.open("PUT", `https://www.googleapis.com/blogger/v3/blogs/${bloggerID}/posts/${bloggerPostID}`, true); req.setRequestHeader("Content-Type", "application/json"); req.setRequestHeader("Authorization", "Bearer " + userToken); req.send(JSON.stringify(data)); }); } async function getModsUpdate(updates_json) { app_updates.innerHTML = ``; app_screenshots.innerHTML = ``; let keys = Object.keys(updates_json); keys.splice(keys.indexOf('auth'), 1); keys.reverse(); for (const key of keys) { if (key == "auth") return; let item = updates_json[key]; app_updates.innerHTML += `<div class="item"> <i class="large arrow circle up green middle aligned icon"></i> <div class="content"> <a href="${item.upd}" class="header">${item.logs}</a> <div class="description">${moment(new Date(item.date)).fromNow()}</div> </div> </div>`; app_screenshots.innerHTML += ` <a id="${key}" class="item" onclick="appendImages('${key}', '${btoa(JSON.stringify(item.imgs))}');"> Screenshots for ${key} <i class="eye icon"></i> </a>`; } } function qt(id) { return document.querySelector(`[${id}]`); } function query(id) { return document.getElementById(id); } async function checkIfUserIsAdmin() { let { data, error } = await supabase.auth.getSession(); if (error) { window.alert(`${error.message}`); return; } if (!data.session || data.length == 0) { window.alert("Invalid Authorization. Not Admin!"); return; } if (data.session.user.id != 'd1d960f1-a364-4d15-909e-073127bef432') { window.alert("Invalid Authorization. Not Admin!"); return; } return "Valid!"; } function checkIfUserLoggedInBlogger() { if (!localStorage.getItem('userBloggerToken')) { window.alert("You need to log in to Blogger first!"); localStorage.setItem('beforeOauthUrl', window.location.href); window.location.href = 'https://storehaccounts.blogspot.com/p/blogger-users-landing-point.html'; } return JSON.parse(localStorage.getItem('userBloggerToken')).token; } window.appendImages = (key, data) => { let arr_imgs = atob(data); arr_imgs = JSON.parse(arr_imgs); document.getElementById('gallery').innerHTML = ``; arr_imgs.forEach(item => { let html = `<div class="column"> <img style="cursor: pointer;" onclick="window.open('${item}')" src=${item}/> </div>`; document.getElementById('gallery').innerHTML += html; }); document.getElementById(key).parentNode.insertBefore(document.getElementById('gallery'), document.getElementById(key).nextSibling); if (document.getElementById('gallery').style.display == 'block') document.getElementById('gallery').style.display = 'none'; else document.getElementById('gallery').style.display = 'block'; } document.getElementById('btnUpdatePost').addEventListener('click', async() => { document.getElementById('btnUpdatePost').classList.add('loading', 'disable'); // get token // get html // get the thumbnail of the post let thumb_img = document.querySelector('#div_parent').querySelector('img').src; let data = { "kind": "blogger#post", "id": blogpostid, "blog": { "id": blogid }, "labels": [ "Official" ], "published": new Date(), "updated": new Date(), "title": blogposttitle + ' (' + blogpostversion + ')', "content": document.querySelector('#div_parent').innerHTML }; await updateBlogPost(blogger_token, blogid, blogpostid, data); document.getElementById('btnUpdatePost').classList.remove('loading', 'disable'); }); }, false); </script>