LOGIN
Sign in to enter HtStudio. An account is required.
';
document.body.appendChild(ov);
ov.querySelector('#hts-ad-close').onclick = function(){ ov.style.display = 'none'; };
ov.querySelector('#hts-ad-upgrade').onclick = function(){
ov.style.display = 'none';
if (typeof openUpgradeModal === 'function') openUpgradeModal();
};
}
ov.style.display = 'flex';
};
window.htsStartAdTimer = function(){
try { if (window._htsAdTimer) clearInterval(window._htsAdTimer); } catch(e){}
window._htsAdTimer = setInterval(function(){
try {
if (typeof isProUser === 'function' && isProUser()) return;
if (window._htsCompiling) return;
htsShowPlanAd();
} catch(e){}
}, 10 * 60 * 1000);
};
setTimeout(function(){ try { htsStartAdTimer(); } catch(e){} }, 5000);
// Account badge: show compile usage under plan
window.htsPaintCompileUsage = function(){
try {
const row = document.getElementById('acc-plan-row');
if (!row) return;
let uel = document.getElementById('acc-compile-usage');
if (!uel) {
uel = document.createElement('div');
uel.id = 'acc-compile-usage';
uel.style.cssText = 'width:100%;font-size:11px;color:var(--text2);margin-top:4px;';
row.appendChild(uel);
}
const lim = (typeof getPlanLimits === 'function' ? getPlanLimits() : { compilesPerDay: 10 }).compilesPerDay;
const u = htsGetCompileUsage();
uel.textContent = 'Compiles today: ' + u.count + ' / ' + (lim > 1000 ? '∞' : lim);
} catch(e){}
};
const _paint = window.paintAccountPlanBadge;
if (typeof _paint === 'function') {
window.paintAccountPlanBadge = function(){
_paint();
try { htsPaintCompileUsage(); } catch(e){}
};
}
window.HTS_OWNERS = [
'beytullahclk2009@gmail.com',
'yusemcol41@gmail.com'
];
window.HTS_PLAN_LIMITS = {
basic: { compilesPerDay: 10, maxBackups: 10, ads: true, priority: false },
pro: { compilesPerDay: 30, maxBackups: 25, ads: false, priority: true },
owner: { compilesPerDay: 999999, maxBackups: 999999, ads: false, priority: true }
};
function htsIsOwnerEmail(email) {
if (!email) return false;
const e = String(email).trim().toLowerCase();
return window.HTS_OWNERS.some(o => o.toLowerCase() === e);
}
function htsDefaultPlanState() {
return { plan: 'basic', planExpiry: 0, source: 'monthly', source: 'default' };
}
window.getUserPlan = function getUserPlan() {
try {
const u = window.currentUser;
if (u && u.email && htsIsOwnerEmail(u.email)) {
return { plan: 'owner', planExpiry: 0, interval: 'owner', source: 'owner' };
}
const raw = localStorage.getItem('hts_plan');
if (!raw) return htsDefaultPlanState();
const p = JSON.parse(raw);
if (!p || !p.plan) return htsDefaultPlanState();
if (p.plan === 'pro' && p.planExpiry && Date.now() > Number(p.planExpiry)) {
return htsDefaultPlanState();
}
if (p.plan === 'pro') return p;
return { plan: 'basic', planExpiry: 0, billing: p.billing || 'monthly', source: p.source || 'local' };
} catch (e) {
return htsDefaultPlanState();
}
};
window.isProUser = function isProUser() {
const p = getUserPlan();
return p.plan === 'pro' || p.plan === 'owner';
};
window.isOwnerUser = function isOwnerUser() {
return getUserPlan().plan === 'owner';
};
window.getPlanLimits = function getPlanLimits() {
const p = getUserPlan().plan;
return window.HTS_PLAN_LIMITS[p] || window.HTS_PLAN_LIMITS.basic;
};
window.saveUserPlanLocal = function saveUserPlanLocal(planObj) {
try { localStorage.setItem('hts_plan', JSON.stringify(planObj)); } catch (e) {}
};
window.syncPlanFromCloud = async function syncPlanFromCloud(uid) {
try {
if (!uid || typeof getDoc !== 'function' || typeof doc !== 'function' || typeof db === 'undefined') return;
const snap = await getDoc(doc(db, 'users', uid));
if (!snap.exists()) return;
const d = snap.data() || {};
const email = (window.currentUser && window.currentUser.email) || '';
if (htsIsOwnerEmail(email)) {
saveUserPlanLocal({ plan: 'owner', planExpiry: 0, billing: 'owner', source: 'owner' });
return;
}
if (d.plan === 'pro') {
const exp = Number(d.planExpiry || 0);
if (!exp || exp > Date.now()) {
saveUserPlanLocal({
plan: 'pro',
planExpiry: exp || 0,
billing: d.planBilling || 'monthly',
source: 'cloud'
});
} else {
saveUserPlanLocal(htsDefaultPlanState());
}
} else {
saveUserPlanLocal(htsDefaultPlanState());
}
} catch (e) {
console.warn('syncPlanFromCloud', e);
}
};
window.paintAccountPlanBadge = function paintAccountPlanBadge() {
const nameEl = document.getElementById('acc-name');
if (!nameEl) return;
let row = document.getElementById('acc-plan-row');
if (!row) {
row = document.createElement('div');
row.id = 'acc-plan-row';
row.style.cssText = 'display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-top:6px;';
const emailEl = document.getElementById('acc-email');
if (emailEl && emailEl.parentElement) emailEl.parentElement.appendChild(row);
else nameEl.parentElement.appendChild(row);
}
const p = getUserPlan();
let badge = '';
let upgrade = '';
if (p.plan === 'owner') {
badge = '
Owner';
} else if (p.plan === 'pro') {
badge = '
Pro';
} else {
badge = '
Basic';
upgrade = '
Upgrade';
}
row.innerHTML = badge + upgrade;
};
window.openUpgradeModal = function openUpgradeModal() {
const hint = document.getElementById('upgrade-hint');
const isApp = !!(window.Android);
if (hint) {
if (isApp) {
hint.textContent = 'Payment via Google Play will be connected next. Owners already have full access.';
} else {
hint.textContent = 'Pro purchase is available in the HtStudio Android app. Your Pro tag will appear here automatically (same Google account).';
}
}
const bm = document.getElementById('btn-buy-monthly');
const by = document.getElementById('btn-buy-yearly');
if (bm) bm.style.display = isApp ? 'block' : 'none';
if (by) by.style.display = isApp ? 'block' : 'none';
if (!isApp && hint) {
/* site: still show a single CTA */
if (bm) {
bm.style.display = 'block';
bm.textContent = 'Get Pro in the Android app';
bm.onclick = function () {
try { goPage('download'); closeM('m-upgrade'); } catch (e) { closeM('m-upgrade'); }
};
}
if (by) by.style.display = 'none';
} else {
if (bm) {
bm.textContent = 'Get Pro · Monthly 79 ₺';
bm.onclick = function () { subscribePro('monthly'); };
}
if (by) {
by.textContent = 'Get Pro · Yearly 799 ₺';
by.onclick = function () { subscribePro('yearly'); };
}
}
const ov = document.getElementById('m-upgrade');
if (ov) ov.classList.add('active');
};
window.requirePro = function requirePro(featureMsg) {
if (isProUser()) return true;
const msg = document.getElementById('pro-gate-msg');
if (msg) {
msg.textContent = featureMsg ||
'This feature is available on HtStudio Pro. Upgrade for higher limits, no ads, and priority compiles.';
}
const ov = document.getElementById('m-pro-gate');
if (ov) ov.classList.add('active');
return false;
};
window.playProCelebrate = function playProCelebrate() {
const root = document.getElementById('pro-celebrate');
const hat = document.getElementById('pro-hat');
const crown = document.getElementById('pro-crown');
const msg = document.getElementById('pro-cele-msg');
if (!root) return;
root.classList.add('show');
if (hat) hat.style.display = 'block';
if (crown) crown.classList.remove('show');
if (msg) msg.textContent = 'Welcome to Pro';
setTimeout(function () {
if (hat) hat.style.display = 'none';
if (crown) crown.classList.add('show');
if (msg) msg.textContent = 'You are Pro 👑';
}, 1600);
setTimeout(function () {
root.classList.remove('show');
if (hat) hat.style.display = 'block';
if (crown) crown.classList.remove('show');
try { paintAccountPlanBadge(); } catch (e) {}
}, 3400);
};
window.onProPurchaseResult = function(ok, billing, msg) {
if (!ok) {
if (msg && /cancel/i.test(msg)) return;
alert(msg || 'Purchase failed');
return;
}
billing = billing === 'yearly' ? 'yearly' : 'monthly';
const ms = billing === 'yearly' ? 365*24*60*60*1000 : 30*24*60*60*1000;
const planObj = {
plan: 'pro',
planExpiry: Date.now() + ms,
billing: billing,
source: 'play'
};
try { saveUserPlanLocal(planObj); } catch(e){}
(async function(){
try {
const u = window.currentUser;
if (u && typeof setDoc === 'function' && typeof doc === 'function' && typeof db !== 'undefined') {
await setDoc(doc(db, 'users', u.uid), {
plan: 'pro',
planExpiry: planObj.planExpiry,
planBilling: billing,
planUpdated: Date.now(),
planSource: 'play'
}, { merge: true });
}
} catch(e){ console.warn(e); }
try { closeM('m-upgrade'); } catch(e){}
try { playProCelebrate(); } catch(e){}
try { paintAccountPlanBadge(); } catch(e){}
})();
};
window.subscribePro = async function subscribePro(billing) {
billing = billing === 'yearly' ? 'yearly' : 'monthly';
const u = window.currentUser;
if (!u) { alert('Sign in first.'); return; }
if (typeof htsIsOwnerEmail === 'function' && htsIsOwnerEmail(u.email)) {
saveUserPlanLocal({ plan: 'owner', planExpiry: 0, billing: 'owner', source: 'owner' });
try { closeM('m-upgrade'); } catch(e){}
try { playProCelebrate(); } catch(e){}
return;
}
// Real Play Billing in app
if (window.Android && typeof window.Android.purchasePro === 'function') {
try {
window.Android.purchasePro(billing);
return;
} catch (e) {
alert('Could not start Google Play purchase.');
return;
}
}
// Website: cannot charge — send to app
alert('Pro is purchased in the HtStudio Android app. Sign in with the same Google account — your Pro tag will sync here.');
try { if (typeof goPage === 'function') goPage('download'); } catch(e){}
try { closeM('m-upgrade'); } catch(e){}
};
// Wrap updateAccountUI
(function () {
const _upd = window.updateAccountUI;
window.updateAccountUI = function (user) {
if (typeof _upd === 'function') _upd(user);
else {
try {
document.getElementById('acc-guest').style.display = 'none';
document.getElementById('acc-user').style.display = 'flex';
document.getElementById('acc-photo').src = user.photoURL || '';
document.getElementById('acc-name').textContent = user.displayName || '';
document.getElementById('acc-email').textContent = user.email || '';
} catch (e) {}
}
if (user && htsIsOwnerEmail(user.email)) {
saveUserPlanLocal({ plan: 'owner', planExpiry: 0, billing: 'owner', source: 'owner' });
}
try { if (user && user.uid) syncPlanFromCloud(user.uid).then(function(){ paintAccountPlanBadge(); }); } catch (e) {}
try { paintAccountPlanBadge(); } catch (e) {}
};
})();
window.signInGoogle){ window.signInGoogle(); } else { alert('Login is still loading, wait 1 second and try again.'); }">Login with Google
Success