modifying...

This commit is contained in:
CatAClock 2025-05-02 15:07:20 -07:00
parent bf738b63d3
commit 0f420b6eb9
14 changed files with 114 additions and 24 deletions

View file

@ -205,6 +205,13 @@ html {
border-width: 1px; border-width: 1px;
} }
.Posting {
border-style: solid;
border-width: 1px;
margin-right: 5%;
}
.MainFooter { .MainFooter {
display: flex; display: flex;
margin-top: 75vh; margin-top: 75vh;

1
CSS/post.css Normal file
View file

@ -0,0 +1 @@

0
CSS/setting.css Normal file
View file

21
HTML/post.html Normal file
View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/post.css">
<script type="module" src="../JS/post.js"></script>
<!-- Dependenci -->
<script language="JavaScript" type="text/javascript" src="https://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js"></script>
</head>
<body style="margin: 0px; text-align: center;">
<header>
<h1>Post</h1>
<textarea cols="50" rows="25" class="text" placeholder="status here..."></textarea>
<p class="button">POST!</p>
</header>
<p onclick="history.back()"><b>Back</b></p>
</body>
</html>

View file

@ -4,7 +4,7 @@
<title>The Fediverse</title> <title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!"> <meta name="description" content="Change the fucking channel already!">
<link rel="icon" href="../Icons/favicon.ico" /> <link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/setting.css">
<script type="module" src="../JS/setting.js"></script> <script type="module" src="../JS/setting.js"></script>
<!-- Dependenci --> <!-- Dependenci -->
<script language="JavaScript" type="text/javascript" src="https://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js"></script> <script language="JavaScript" type="text/javascript" src="https://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js"></script>
@ -17,10 +17,10 @@
<p class="Local">Toggle Local</p> <p class="Local">Toggle Local</p>
<p class="Remote">Toggle Remote</p> <p class="Remote">Toggle Remote</p>
<p class="Login Mastodon"><em>Login to Mastodon</em></p> <p class="Login Mastodon"><em>Login to Mastodon</em></p>
<input type="text" minlength="6" class="WebInput Mastodon" required /> <input type="text" class="WebInput Mastodon" placeholder="The website your account is on."/>
<p class="Logout Mastodon" style="visibility: hidden;"><em>Logout of Mastodon</em></p> <p class="Logout Mastodon" style="visibility: hidden;"><em>Logout of Mastodon</em></p>
<p class="Login Bluesky"><em>Login to Bluesky</em></p> <p class="Login Bluesky"><em>Login to Bluesky</em></p>
<input type="text" minlength="6" class="WebInput Bluesky" required /> <input type="text" class="WebInput Bluesky" />
<p class="Logout Bluesky" style="visibility: hidden;"><em>Logout of Bluesky</em></p> <p class="Logout Bluesky" style="visibility: hidden;"><em>Logout of Bluesky</em></p>
<p onclick="history.back()"><b>OK</b></p> <p onclick="history.back()"><b>OK</b></p>
</body> </body>

View file

@ -156,7 +156,7 @@ export async function GainTokens() {
let WellKnown = await GetPDSWellKnown(); let WellKnown = await GetPDSWellKnown();
// Check to see if something's a miss... // Check to see if something's a miss...
if ((document.location.href.split("state=").length > 1 && document.location.href.split("iss=").length > 1 && document.location.href.split("code=").length > 1) && Cookie.IsCookieReal(Cookie.BlueskyPKCEVeriferCookie)) { if ((document.location.href.split("state=").length > 1 && document.location.href.split("iss=").length > 1 && document.location.href.split("code=").length > 1) && Cookie.IsCookieReal(Cookie.BlueskyPKCEVeriferCookie) && !(Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie))) {
// Create varaibles, be aware of waits because of internet. // Create varaibles, be aware of waits because of internet.
let DPoP = await ClientDPoPToken("POST", WellKnown.token_endpoint); let DPoP = await ClientDPoPToken("POST", WellKnown.token_endpoint);
let code = document.location.href.split("code=")[1]; let code = document.location.href.split("code=")[1];

View file

@ -1,6 +1,6 @@
// STRINGS TODO: make sure to seperate stuff that a user will want to input. Ex: MastodonWebsiteName, BlueskyPDS, etc. // STRINGS TODO: make sure to seperate stuff that a user will want to input. Ex: MastodonWebsiteName, BlueskyPDS, etc.
// Mastodon // Mastodon
export const MastodonWebsiteName = "https://wetdry.world"; export const MastodonWebsiteName = "mastodon_website";
export const MastodonClientIDName = "mastodon_client_id"; export const MastodonClientIDName = "mastodon_client_id";
export const MastodonClientSecretName = "mastodon_client_secret"; export const MastodonClientSecretName = "mastodon_client_secret";
export const MastodonAccessTokenName = "mastodon_access_token"; export const MastodonAccessTokenName = "mastodon_access_token";
@ -22,6 +22,7 @@ export const TumblrWebsiteName = "https://www.tumblr.com";
// COOKIES TODO: person inputted stuff (like MastodonWebsiteName) should be implemented. // COOKIES TODO: person inputted stuff (like MastodonWebsiteName) should be implemented.
// Mastodon // Mastodon
export const MastodonWebsiteCookie = GetCookie(MastodonWebsiteName);
export const MastodonClientIDCookie = GetCookie(MastodonClientIDName); export const MastodonClientIDCookie = GetCookie(MastodonClientIDName);
export const MastodonClientSecretCookie = GetCookie(MastodonClientSecretName); export const MastodonClientSecretCookie = GetCookie(MastodonClientSecretName);
export const MastodonAccessTokenCookie = GetCookie(MastodonAccessTokenName); export const MastodonAccessTokenCookie = GetCookie(MastodonAccessTokenName);

View file

@ -4,6 +4,7 @@ export const Scopes = "read write follow push";
// Gets the public timeline. // Gets the public timeline.
export async function GetPublicTimeline(Local = false, Remote = false, Website) { export async function GetPublicTimeline(Local = false, Remote = false, Website) {
// Cookies can be found in `setting.js`
let Timeline; let Timeline;
if (Local == true && Remote == true) { if (Local == true && Remote == true) {
console.error("Don't set both Local and Remote timelines to true."); console.error("Don't set both Local and Remote timelines to true.");
@ -24,10 +25,11 @@ export async function GetPublicTimeline(Local = false, Remote = false, Website)
} }
// Gets the favorites of a user that you have access to. // Gets the favorites of a user that you have access to.
export async function GetFavorites(Website) { export async function GetFavorites() {
let Favorites; let Favorites;
// Check for a token. // Check for a token.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) { if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
// Get the varaibles that are stored in cookies. // Get the varaibles that are stored in cookies.
Favorites = await fetch(Website + "/api/v1/favourites", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}}) Favorites = await fetch(Website + "/api/v1/favourites", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json()); .then((response) => response.json());
@ -36,10 +38,11 @@ export async function GetFavorites(Website) {
} }
// Gets the bookmarks of a user that you have access to. // Gets the bookmarks of a user that you have access to.
export async function GetBookmarks(Website) { export async function GetBookmarks() {
let Bookmarks; let Bookmarks;
// Check for a token. // Check for a token.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) { if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
// Get the varaibles that are stored in cookies. // Get the varaibles that are stored in cookies.
Bookmarks = await fetch(Website + "/api/v1/bookmarks", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}}) Bookmarks = await fetch(Website + "/api/v1/bookmarks", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json()); .then((response) => response.json());
@ -48,10 +51,11 @@ export async function GetBookmarks(Website) {
} }
// Gets the notifications of a user that you have access to. // Gets the notifications of a user that you have access to.
export async function GetNotifications(Website) { export async function GetNotifications() {
let Notifications; let Notifications;
// Check for a token. // Check for a token.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) { if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
// Get the varaibles that are stored in cookies and then input it. // Get the varaibles that are stored in cookies and then input it.
Notifications = await fetch(Website + "/api/v1/notifications", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}}) Notifications = await fetch(Website + "/api/v1/notifications", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json()); .then((response) => response.json());
@ -59,6 +63,16 @@ export async function GetNotifications(Website) {
return Notifications; return Notifications;
} }
// Make a status
export async function CreateStatus(Text) {
// Check for a token
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
return await fetch(Website + "/api/v1/statuses?status=" + Text , {method: "POST", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json());
}
}
// The first step to using the app. // The first step to using the app.
export async function HandleAuthentication(Website) { export async function HandleAuthentication(Website) {
// See if the user is smart enough to put https. // See if the user is smart enough to put https.
@ -69,6 +83,8 @@ export async function HandleAuthentication(Website) {
} else { } else {
Website = "https://" + Website; Website = "https://" + Website;
} }
// Save the website
Cookie.InputCookie(Cookie.MastodonWebsiteName, Website);
// Registering the app. // Registering the app.
InstanceData = await fetch(Website + "/api/v1/apps?client_name=Channel Viewer&redirect_uris=" + document.location.href + "&scopes=" + Scopes, {method: "POST"}) InstanceData = await fetch(Website + "/api/v1/apps?client_name=Channel Viewer&redirect_uris=" + document.location.href + "&scopes=" + Scopes, {method: "POST"})
.then((response) => response.json()); .then((response) => response.json());
@ -80,14 +96,16 @@ export async function HandleAuthentication(Website) {
} }
// This specific functino goes after HandleAuthentication for when login happens. // This specific functino goes after HandleAuthentication for when login happens.
export async function GainToken(Website) { export async function GainToken() {
// check if you both have a code and have a current authentication. // check if you both have a code and have a current authentication.
if (document.location.href.split("code=").length > 1 && Cookie.IsCookieReal(Cookie.MastodonClientIDCookie)) { if (document.location.href.split("code=").length > 1 && Cookie.IsCookieReal(Cookie.MastodonClientIDCookie) && !(Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie))) {
// Get some vars.
let code = document.location.href.split("code=")[1]; let code = document.location.href.split("code=")[1];
let Website = Cookie.MastodonWebsiteCookie;
// Authenticate.
let AuthenticationToken = await fetch(Website + "/oauth/token?client_id=" + Cookie.MastodonClientIDCookie + "&client_secret=" + Cookie.MastodonClientSecretCookie + "&redirect_uri=" + document.location.href + "&grant_type=authorization_code&code=" + code, {method: "POST"}) let AuthenticationToken = await fetch(Website + "/oauth/token?client_id=" + Cookie.MastodonClientIDCookie + "&client_secret=" + Cookie.MastodonClientSecretCookie + "&redirect_uri=" + document.location.href + "&grant_type=authorization_code&code=" + code, {method: "POST"})
.then((response) => response.json()); .then((response) => response.json());
// Cookify These // Cookify These.
Cookie.InputCookie(Cookie.MastodonAccessTokenName, AuthenticationToken.access_token); Cookie.InputCookie(Cookie.MastodonAccessTokenName, AuthenticationToken.access_token);
Cookie.InputCookie(Cookie.MastodonTokenTypeName, AuthenticationToken.token_type); Cookie.InputCookie(Cookie.MastodonTokenTypeName, AuthenticationToken.token_type);
} }

View file

@ -0,0 +1 @@
import * as Cookie from "./Cookies.js";

View file

@ -15,6 +15,7 @@ let BrowserHeight = window.innerHeight;
let ArrowsButton = document.getElementsByClassName("Arrow"); let ArrowsButton = document.getElementsByClassName("Arrow");
let SettingButton = document.getElementsByClassName("Setting")[0]; let SettingButton = document.getElementsByClassName("Setting")[0];
let MailButton = document.getElementsByClassName("Mail")[0]; let MailButton = document.getElementsByClassName("Mail")[0];
let PostingButton = document.getElementsByClassName("Posting")[0];
// Sounds // Sounds
const ButtonSound = new Audio("Audio/button-305770.mp3"); const ButtonSound = new Audio("Audio/button-305770.mp3");
@ -108,8 +109,13 @@ async function PosterContainerUpdate() {
var LocalTrue = (LocalCookie === "true"); var LocalTrue = (LocalCookie === "true");
let RemoteCookie = Cookie.GetCookie("Remote"); let RemoteCookie = Cookie.GetCookie("Remote");
var RemoteTrue = (RemoteCookie === "true"); var RemoteTrue = (RemoteCookie === "true");
let Website = Cookie.MastodonWebsiteCookie;
let Timeline = await MastodonAPI.GetPublicTimeline(LocalTrue, RemoteTrue, Cookie.MastodonWebsiteName); if (!(Cookie.IsCookieReal(Cookie.MastodonWebsiteCookie))) {
Website = "https://wetdry.world";
}
let Timeline = await MastodonAPI.GetPublicTimeline(LocalTrue, RemoteTrue, Website);
let Content = []; let Content = [];
let Users = []; let Users = [];
for (let i in Timeline) { for (let i in Timeline) {
@ -128,7 +134,12 @@ SettingButton.onclick = (event) => {
window.location.href = "./HTML/setting.html"; window.location.href = "./HTML/setting.html";
} }
// Open the notifs, private message, favorites, bookmarks // Open the notifs, private message, favorites, ... anything mail related!
MailButton.onclick = (event) => { MailButton.onclick = (event) => {
window.location.href = "./HTML/mail.html"; window.location.href = "./HTML/mail.html";
} }
// Open the posting area
PostingButton.onclick = (event) => {
window.location.href = "./HTML/post.html";
}

View file

@ -5,7 +5,7 @@ import * as Cookie from "./Cookies.js";
// Below is the thing it populates if you login. // Below is the thing it populates if you login.
async function PopulateFavorites() { async function PopulateFavorites() {
let Favorites = await MastodonAPI.GetFavorites(Cookie.MastodonWebsiteName); let Favorites = await MastodonAPI.GetFavorites();
let FavoritesArea = document.getElementsByClassName("Favorites")[0]; let FavoritesArea = document.getElementsByClassName("Favorites")[0];
// Populate the favorites area. // Populate the favorites area.
@ -16,7 +16,7 @@ async function PopulateFavorites() {
} }
async function PopulateBookmarks() { async function PopulateBookmarks() {
let Bookmarks = await MastodonAPI.GetBookmarks(Cookie.MastodonWebsiteName); let Bookmarks = await MastodonAPI.GetBookmarks();
let BookmarksArea = document.getElementsByClassName("Bookmarks")[0]; let BookmarksArea = document.getElementsByClassName("Bookmarks")[0];
// Populate the Bookmarks area. // Populate the Bookmarks area.
@ -27,7 +27,7 @@ async function PopulateBookmarks() {
} }
async function PopulateNotifications() { async function PopulateNotifications() {
let Notifications = await MastodonAPI.GetNotifications(Cookie.MastodonWebsiteName); let Notifications = await MastodonAPI.GetNotifications();
let NotificationsArea = document.getElementsByClassName("Notifications")[0]; let NotificationsArea = document.getElementsByClassName("Notifications")[0];
// Populate the Conversations area. // Populate the Conversations area.

25
JS/post.js Normal file
View file

@ -0,0 +1,25 @@
import * as MastodonAPI from "./MastodonAPI.js";
import * as BlueskyAPI from "./BlueskyAPI.js";
import * as TumblrAPI from "./TumblrAPI.js";
import * as Cookie from "./Cookies.js";
// Elements.
let PostButton = document.getElementsByClassName("button")[0];
let InputArea = document.getElementsByClassName("text")[0];
// Clicking the beeg POST button.
PostButton.onclick = (event) => {
Post();
}
async function Post() {
let Text = InputArea.value;
// Mastodon posting.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
MastodonAPI.CreateStatus(Text);
}
// Bluesky posting.
if (Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie)) {
}
}

View file

@ -14,6 +14,9 @@ let BlueskyLoginButton = document.getElementsByClassName("Login Bluesky")[0];
let BlueskyWebInput = document.getElementsByClassName("WebInput Bluesky")[0]; let BlueskyWebInput = document.getElementsByClassName("WebInput Bluesky")[0];
let BlueskyLogoutButton = document.getElementsByClassName("Logout Bluesky")[0]; let BlueskyLogoutButton = document.getElementsByClassName("Logout Bluesky")[0];
// original link
let Origin = location.origin + "/HTML/setting.html"
// Change weather the timelines are public or remote // Change weather the timelines are public or remote
LocalButton.onclick = (event) => { LocalButton.onclick = (event) => {
// Toggle the cookie // Toggle the cookie
@ -36,8 +39,9 @@ RemoteButton.onclick = (event) => {
// Mastodon buttons // Mastodon buttons
// Login // Login
MastodonLoginButton.onclick = (event) => { MastodonLoginButton.onclick = (event) => {
if (MastodonWebInput != "") { if (MastodonWebInput.value != "") {
MastodonAPI.HandleAuthentication(Cookie.MastodonWebsiteName); let text = MastodonWebInput.value
MastodonAPI.HandleAuthentication(text);
} }
} }
@ -47,13 +51,13 @@ MastodonLogoutButton.onclick = (event) => {
Cookie.ExpireCookie(Cookie.MastodonClientSecretName); Cookie.ExpireCookie(Cookie.MastodonClientSecretName);
Cookie.ExpireCookie(Cookie.MastodonAccessTokenName); Cookie.ExpireCookie(Cookie.MastodonAccessTokenName);
Cookie.ExpireCookie(Cookie.MastodonTokenTypeName); Cookie.ExpireCookie(Cookie.MastodonTokenTypeName);
document.location.href = document.location.href; document.location.href = Origin;
} }
// Bluesky Buttons // Bluesky Buttons
// Login // Login
BlueskyLoginButton.onclick = (event) => { BlueskyLoginButton.onclick = (event) => {
if (BlueskyWebInput != "") { if (BlueskyWebInput.value != "") {
BlueskyAPI.HandleAuthorization(); BlueskyAPI.HandleAuthorization();
} }
} }
@ -67,7 +71,7 @@ BlueskyLogoutButton.onclick = (event) => {
Cookie.ExpireCookie(Cookie.BlueskyRefreshTokenName); Cookie.ExpireCookie(Cookie.BlueskyRefreshTokenName);
Cookie.ExpireCookie(Cookie.BlueskyPublicKeyName); Cookie.ExpireCookie(Cookie.BlueskyPublicKeyName);
Cookie.ExpireCookie(Cookie.BlueskyPrivateKeyName); Cookie.ExpireCookie(Cookie.BlueskyPrivateKeyName);
document.location.href = document.location.href; document.location.href = Origin;
} }
// if an access token is found, login. // if an access token is found, login.
@ -80,7 +84,7 @@ async function CheckLogin() {
MastodonLogoutButton.setAttribute("style", ""); MastodonLogoutButton.setAttribute("style", "");
} else { } else {
// Auto log in // Auto log in
MastodonAPI.GainToken(Cookie.MastodonWebsiteName); await MastodonAPI.GainToken(Cookie.MastodonWebsiteName);
} }
// Check for a bluesky token. // Check for a bluesky token.
if (Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie)) { if (Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie)) {
@ -90,7 +94,7 @@ async function CheckLogin() {
BlueskyLogoutButton.setAttribute("style", ""); BlueskyLogoutButton.setAttribute("style", "");
} else { } else {
// Auto log in // Auto log in
BlueskyAPI.GainTokens(); await BlueskyAPI.GainTokens();
} }
} }

View file

@ -292,6 +292,7 @@
<footer class="MainFooter"> <footer class="MainFooter">
<p class="Setting">Setting</p> <p class="Setting">Setting</p>
<p class="Time" style="width: 50%">Time</p> <p class="Time" style="width: 50%">Time</p>
<p class="Posting">Post</p>
<p class="Mail">Mail</p> <p class="Mail">Mail</p>
</footer> </footer>
</section> </section>