Merge pull request 'main' (#5) from ashley/poke:main into main

Reviewed-on: https://codeberg.org/Korbs/poke/pulls/5
This commit is contained in:
Korbs 2024-05-12 19:27:39 +00:00
commit e3b35a4426
11 changed files with 3200 additions and 3653 deletions

33
css/maps.js Normal file
View file

@ -0,0 +1,33 @@
var bbox = "?bbox=-165.76171875000003%2C-3.864254615721396%2C30.410156250000004%2C72.44879155730672&layer=mapnik"
var iframe = document.getElementById('myFrame');
iframe.src=`https://www.openstreetmap.org/export/embed.html${bbox}`
iframe.addEventListener('load', function() {
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var links = iframeDocument.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
links[i].addEventListener('click', function(event) {
var url = event.target.href;
if (url.includes('www.openstreetmap.org')) {
event.preventDefault();
iframe.src = url;
window.history.pushState(null, '', url);
} else {
window.location.href = url;
}
});
}
});
window.onpopstate = function(event) {
iframe.src = window.location.href;
};
iframe.addEventListener('load', function() {
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var elements = iframeDocument.querySelectorAll('[style*="//dka575ofm4ao0.cloudfront.net"]');
for (var i = 0; i < elements.length; i++) {
var style = elements[i].style.backgroundImage;
var newStyle = style.replace('//dka575ofm4ao0.cloudfront.net', 'https://p.poketube.fun/https://dka575ofm4ao0.cloudfront.net');
elements[i].style.backgroundImage = newStyle;
}
});

View file

@ -63,10 +63,10 @@ var apiurl = "https://poketube.fun/api"
if(!localStorage.getItem("UserID")) {
localStorage.setItem('UserID', `<%- userid %>`);
<% db.set(`user.${userid}`, userid) %>
location.href = "/my-acc?ID=" + `<%- userid %>`
location.href = "/my-acc?ID=" + `<%- userid %>` + "&rparam=1"
}
if(localStorage.getItem("UserID")) {
location.href = "/my-acc?ID=" + localStorage.getItem("UserID")
location.href = "/my-acc?ID=" + localStorage.getItem("UserID") + "&rparam=1"
}
</script>

View file

@ -44,40 +44,6 @@
//--><!]]>
</script>
<script>
var bbox = "?bbox=-165.76171875000003%2C-3.864254615721396%2C30.410156250000004%2C72.44879155730672&amp;layer=mapnik"
var iframe = document.getElementById('myFrame');
iframe.src=`https://www.openstreetmap.org/export/embed.html${bbox}`
iframe.addEventListener('load', function() {
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var links = iframeDocument.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
links[i].addEventListener('click', function(event) {
var url = event.target.href;
if (url.includes('www.openstreetmap.org')) {
event.preventDefault();
iframe.src = url;
window.history.pushState(null, '', url);
} else {
window.location.href = url;
}
});
}
});
window.onpopstate = function(event) {
iframe.src = window.location.href;
};
iframe.addEventListener('load', function() {
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var elements = iframeDocument.querySelectorAll('[style*="//dka575ofm4ao0.cloudfront.net"]');
for (var i = 0; i < elements.length; i++) {
var style = elements[i].style.backgroundImage;
var newStyle = style.replace('//dka575ofm4ao0.cloudfront.net', 'https://p.poketube.fun/https://dka575ofm4ao0.cloudfront.net');
elements[i].style.backgroundImage = newStyle;
}
});
</script>
<script src="/static/maps.js"></script><script src="/static/data-mobile.js"></script>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,9 @@
NodeList.prototype.forEach = Array.prototype.forEach;
</script>
<style>
* {
font-family: "poketube flex" !important
}
@keyframes gradient {
0% {
background-position: 0 50%;
@ -35,19 +37,28 @@
animation: gradient 64s ease infinite;
background-size: 400% 400%;
}
a {
color: #fff;
font-weight: 686;
font-stretch: extra-expanded;
}
.downnav {
position: fixed;
padding:10px;
bottom: 0;
left: 0;
width: 100%;
margin: auto;
overflow: hidden;
z-index: 1;
color:#fff;
background-color: #0f0f0f;
}</style>
background-color: #0007;
border-radius: 5px;
width: calc(100% - 33px);
margin-left: 6px;
}
</style>
<script>
<!--//--><![CDATA[//><!--
/**
@ -219,18 +230,16 @@
<input placeholder="Search the web" name="query" autocomplete="off" id="search_form_input_homepage" class="search__input" type="text" autofocus />
<div>
<button class="btn btn-success" type="submit" style="margin-top: 1em;margin-left: auto;text-align: center;display: flex;flex-direction: column;background: #fff;background-color: #303134;border: 1px solid #303134;border-radius: 4px;color: #e8eaed;font-family: arial,sans-serif;font-size: 14px;padding: 0 16px;line-height: 27px;height: 36px;min-width: 54px;margin-right: 13em;text-align: center;cursor: pointer;user-select: none;">
<button class="btn btn-success" type="submit" style="margin-top: 1em;margin-left: auto;text-align: center;display: flex;flex-direction: column;background: #fff;background-color: #303134;border: 1px solid #303134;border-radius: 4px;color: #e8eaed;font-family: arial,sans-serif;font-size: 14px;padding: 0 16px;line-height: 27px;height: 36px;min-width: 54px;margin-right: 9em;text-align: center;cursor: pointer;user-select: none;">
<p style="margin-top: auto;margin-bottom: auto;font-weight: 1000;margin-left: 6px;font-stretch: ultra-expanded;font-family:&quot;poketube flex&quot;;Poketube flex;">Search Poke</p>
</button>
<button class="btn btn-success" name="lucky" value="true" type="submit" style="margin-top: 1em;margin-left: auto;text-align: center;display: flex;flex-direction: column;background: #fff;background-color: #303134;border: 1px solid #303134;border-radius: 4px;color: #e8eaed;font-family: arial,sans-serif;font-size: 14px;padding: 0 16px;line-height: 27px;height: 36px;min-width: 54px;margin-right: 9em;text-align: center;cursor: pointer;user-select: none;margin-top: -38px;margin-left: 21em;">
<p style="margin-top: auto;margin-bottom: auto;font-weight: 1000;margin-left: 6px;font-stretch: ultra-expanded;font-family:&quot;poketube flex&quot;;Poketube flex;">Im feeling lucky</p>
</button>
<div style="margin-left: 5.5em;margin-right: auto;width: fit-content;color: #fff;font-weight: 1000;font-stretch: ultra-expanded;font-size: 33px;margin-bottom: -1em;margin-top: 6px;" id="clock"></div>
<span style="color:#fff;margin-left: auto;margin-right: 8em;text-align: center;display: flex;width: fit-content;margin-top: 2em;font-size: ;" id="weatherInfo"></span>
</div>
</form>
<div class="downnav">
<span style="color:#fff;" id="weatherInfo"></span> - <a style="color:#fff" href="/translate"> Translate </a> - <a style="color:#fff" href="/map"> PokeMaps </a> - <a style="color:#fff" href="/account-create">My Account</a> - <a style="color:#fff" href="/privacy">Privacy</a> - <a style="color:#fff" href="https://codeberg.org/ashley/poketube">Git</a>
<a style="color:#fff" href="/translate"> Translate </a> - <a style="color:#fff" href="/map"> PokeMaps </a> - <a style="color:#fff" href="/account-create">My Account</a> - <a style="color:#fff" href="/privacy">Privacy</a> - <a style="color:#fff" href="https://codeberg.org/ashley/poketube">Git</a>
<div style="float: right;">
<a style="color:#fff" id="osInfo"></a> <a style="color:#fff;margin-right: 1em;" href="/license">License</a>
</div>
@ -257,6 +266,27 @@ if (userAgent.includes("windows")) {
const osInfoElement = document.getElementById("osInfo");
osInfoElement.textContent = `${osName} - `;
function updateClock() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
// Add leading zeros to minutes and seconds
minutes = (minutes < 10 ? "0" : "") + minutes;
seconds = (seconds < 10 ? "0" : "") + seconds;
// Display the time in the "clock" div
document.getElementById("clock").innerHTML = hours + ":" + minutes + ":" + seconds;
// Update the clock every second
setTimeout(updateClock, 1000);
}
// Call the function to initially display the clock
updateClock();
</script> <script>
const css = localStorage.getItem("poke-custom-css");
@ -320,7 +350,7 @@ if (window.location.hostname === "poketube.fun" && config.plausible_enabled == t
// Call the fetchAndDisplayWeather function when the page loads
fetchAndDisplayWeather();
</script><script src="/static/emojis.js"></script><style> img.emoji {height: 1em;width: 1em;margin: 0 .05em 0 .1em;vertical-align: -0.1em;}</style>
</script><script src="/static/emojis.js"></script><script src="/static/data-mobile.js"></script><style> img.emoji {height: 1em;width: 1em;margin: 0 .05em 0 .1em;vertical-align: -0.1em;}</style>
<script>twemoji.parse(document.body,{ base: 'https://p.poketube.fun/https://cdn.zptr.cc/twemoji/' })</script></div>
</div> <!-- id="content_homepage" -->
</div> <!-- id="content_wrapper_homepage" -->

View file

@ -546,6 +546,7 @@ font-weight: 1000;
<div style="display: flex; flex-direction: column; row-gap: 8px;font-weight:bold">
<a href="/watch?v=<%= x.videoId %>"><span><%= x.viewCountText %></span> <span>•</span> <span><%= x.publishedText %></span></a>
<a href="/channel?id=<%= x.authorId %>"><%=x.author %></a>
<a href="/download?v=<%= x.videoId %>" style="display: flex;align-self: end;"><i class="fa-light fa-download" style="display: flex;align-self: end;margin-top: 3.1em;font-size: 19px;padding: 5px;border-radius: 18px;margin-left: 16em;"></i></a>
</div>
</div>
</div>

View file

@ -47,6 +47,7 @@ const splash = [
"pika!",
"fsf.org",
"ssfffssfssfffaassssfsdf!",
"𝓯𝓻𝓮𝓪𝓴𝔂poke",
"can you save my hds?",
"sahlo folina!",
"we come for you!",
@ -79,6 +80,7 @@ const splash = [
"men are handsome!",
"enbys are cute!",
"you are cute :3",
"read if cute!",
"stallmansupport.org!!!"
]

View file

@ -70,17 +70,17 @@ app.get("/api/set-channel-subs", async function (req, res) {
channelName: channelToSubName,
avatar: avatar, // Store the avatar URL along with the subscription
});
res.json("user subbed");
res.redirect("/account-create")
} else if (!db.get(`user.${userid}.subs.${channelToSub}`)) {
// If the user has 'subs' but not this particular subscription, add it
db.set(`user.${userid}.subs.${channelToSub}`, {
channelName: channelToSubName,
avatar: avatar, // Store the avatar URL along with the subscription
});
res.json("user subbed");
res.redirect("/account-create")
} else {
// If the user is already subscribed to this channel, send a message indicating so
res.json("user already subscribed");
res.json("ur already subscribed");
}
});
@ -104,10 +104,17 @@ app.get("/account-create", async function (req, res) {
}
});
app.get("/my-acc", async function (req, res) {
var userid = req.query.ID
var userSubs = db.get(`user.${userid}.subs`)
renderTemplate(res, req, "account-me.ejs", { userid, userSubs });
app.get("/my-acc", async function (req, res) {
var userid = req.query.ID;
// Check if userid is more than 7 characters
if (userid.length > 7) {
return res.status(400).json({ error: "IDs can be 7 characters max silly :3" });
}
var userSubs = db.get(`user.${userid}.subs`);
renderTemplate(res, req, "account-me.ejs", { userid, userSubs });
});
};

View file

@ -190,6 +190,13 @@ module.exports = function (app, config, renderTemplate) {
return res.redirect("/");
}
const regex = new RegExp("^([a-zA-Z0-9_-]{11})");
const isMatch = regex.test(v);
if (!isMatch) {
return res.redirect("/");
}
var contentlang = hl || "en-US";
var contentregion = region || "US";

View file

@ -167,7 +167,9 @@ class InnerTubePokeVidious {
*/
isvalidvideo(v) {
if (v != "assets" && v != "cdn-cgi" && v != "404") {
return true;
const regex = new RegExp("^([a-zA-Z0-9_-]{11})");
const isMatch = regex.test(v);
return isMatch;
} else {
return false;
}

View file

@ -41,7 +41,7 @@ class PokeTubeDislikesAPIManager {
* @private
*/
async _getEngagementData() {
const apiUrl = `https://ryd.ggtyler.dev/votes/${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
const apiUrl = `https://ryd-proxy.kavin.rocks/votes/${this.videoId}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
const fallbackUrl = `https://returnyoutubedislikeapi.com/votes?videoId=${this.videoId}`;
const { fetch } = await import("undici");