// ==UserScript== // @name Promote Current Time // @namespace http://tampermonkey.net/ // @version 0.5.5 // @description Enter the current time for promotion. // @author Gameil // @match https://f95zone.to/threads/*/ // @icon https://www.google.com/s2/favicons?domain=f95zone.to // @grant none // @updateURL https://git.zonies.xyz/Ryahn/F95Zone-Scripts/raw/branch/main/quick-promoter.js // @downloadURL https://git.zonies.xyz/Ryahn/F95Zone-Scripts/raw/branch/main/quick-promoter.js // ==/UserScript== (function () { //devs banned from promotion, add or remove dev names to update the list. const bannedList = ['1UP Games', 'AnimArts', 'Bawdy Ink Slinger', 'Beachside Bunnies', 'Black Studios', 'Blue Dragon Studios', 'CutePercentage', 'DEVOLUTION', 'DotArt', 'Holy-Rascals', 'MaxCoffee', 'Mrvision', 'Naykid', 'Sylver Games', 'Eromancer', 'SC', 'Selebus', 'SuccuDev', 'Voracity', 'Vortex Cannon Entertainment', 'ZnelArts', 'Zimon']; var devName = ''; //search dev name const title = document.getElementsByClassName('p-title-value')[0] if(title){ const game_name_ele = title.lastChild; const game_name = game_name_ele.textContent; const dev_name_index = game_name.lastIndexOf('['); if(dev_name_index !== -1) { const dev_name = game_name.slice(dev_name_index); const dev_with_link = document.createElement('a'); devName = dev_name.slice(1,-1); dev_with_link.textContent = dev_name; dev_with_link.href = 'https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator='+devName; dev_with_link.style.color = 'inherit'; game_name_ele.textContent = game_name.slice(0, dev_name_index); title.appendChild(dev_with_link); } } //promote time button add const menuLinkBtn = document.querySelectorAll(".menu-linkRow"); let promoBtn, currentBtn; menuLinkBtn.forEach((el) => { if (el.innerText == "Promote Thread") { promoBtn = el; } }); if (promoBtn) { promoBtn.addEventListener("click", () => { console.log("Clicked Promo Button"); if (!currentBtn) { createBtn(); setTimeout(addBtn, 300); } }); } function createBtn() { //creating enter button currentBtn = document.createElement("button"); currentBtn.type = "button"; currentBtn.title = "Enter Current time"; currentBtn.classList.add("button"); currentBtn.style.cssText = "padding: 0; left: 1em; position: relative;"; currentBtn.innerHTML = ` `; } function addBtn() { const inputGroup = document.querySelector( ".inputGroup--date.inputGroup--joined.inputDate" ); if (!inputGroup) { console.log("Unable to add button, trying again in 500ms"); setTimeout(addBtn, 500); return; } const inputBlock = inputGroup.parentNode; inputBlock.appendChild(currentBtn); currentBtn.addEventListener("click", () => { const dateInput = document.querySelector('[name="promote_time_ymd"]'); const hhInput = document.querySelector('[name="promote_time_hh"]'); const mmInput = document.querySelector('[name="promote_time_mm"]'); const lastpromoteTime = new Date( `${dateInput.value}T${hhInput.value}:${mmInput.value}:00` ); const currentTime = new Date(); const month = currentTime.getMonth() + 1; const date = `${currentTime.getFullYear()}-${month}-${currentTime.getDate()}`; const hour = currentTime.getHours(); const minute = currentTime.getMinutes(); const timeDiff = currentTime.getTime() - lastpromoteTime.getTime(); const messageBlock = document.querySelector(".formRow-explain"); if (timeDiff < 60 * 1000){ //do nothing if time was entered recently (less than 60 seconds) return; } else if ( bannedList.includes(devName)) { //banned from promo check messageBlock.textContent = "The developer is banned from promotion."; messageBlock.style.color = "Red"; messageBlock.style.fontSizeAdjust = 0.6; messageBlock.parentNode.parentNode.parentElement.classList.add("shake"); setTimeout(() => { messageBlock.parentNode.parentNode.parentElement.classList.remove( "shake" ); }, 500); } else if (timeDiff < 14 * 24 * 60 * 60 * 1000) { //recent promotion check messageBlock.textContent = "Warning: This thread was promoted less than two weeks ago."; messageBlock.style.color = "yellow"; messageBlock.style.fontSizeAdjust = 0.6; messageBlock.parentNode.parentNode.parentElement.classList.add("shake"); setTimeout(() => { messageBlock.parentNode.parentNode.parentElement.classList.remove( "shake" ); }, 500); } else { dateInput.value = date; hhInput.options[hour].selected = true; mmInput.options[minute].selected = true; messageBlock.textContent = "Entered Current Time. Click Save to Promote."; messageBlock.style.color = "green"; } }); let style = document.createElement("style"); style.innerHTML = ` .shake { animation: shake 0.3s; } @keyframes shake { 0% { transform: translate(0, 0); } 20% { transform: translate(-10px, 0); } 40% { transform: translate(10px, 0); } 60% { transform: translate(-10px, 0); } 80% { transform: translate(10px, 0); } 100% { transform: translate(0, 0); } } `; document.head.appendChild(style); } })();