OctoSpaccHub/public/HashyMagnet/index.html

181 lines
4.4 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<title>HashyMagnet</title>
<meta name="description" content="Generate Magnet URIs from BitTorrent Hashes!">
<meta property="og:title" content="HashyMagnet">
<meta property="og:description" content="Generate Magnet URIs from BitTorrent Hashes!">
<meta property="og:url" content="https://hub.octt.eu.org/HashyMagnet">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2022-09-07 16:13:28 +02:00
<link href="Bubbles.css" rel="stylesheet">
<link rel="shortcut icon" href="../favicon.png" type="image/x-icon">
2022-09-07 16:13:28 +02:00
<link rel="manifest" href="manifest.json">
2022-09-07 00:20:11 +02:00
<style>
Body {
2022-09-07 16:13:28 +02:00
Color: #FFFFFF;
Background-Color: #254070;
2022-09-07 00:20:11 +02:00
Margin: 0px;
Padding: 16px;
2022-09-07 16:13:28 +02:00
Overflow: Hidden;
Text-Align: Center;
Font-Family: Sans-Serif;
2022-09-07 00:20:11 +02:00
}
2022-09-07 16:13:28 +02:00
Input, Button {
Height: 2em;
Font-Size: Initial;
}
Input, TextArea {
Width: Calc(90% - 8px);
Margin-Top: 8px;
Margin-Bottom: 8px;
}
#Main {
Overflow-Y: Scroll;
Max-Height: 100vh;
Position: Absolute;
Top: 50%;
Transform: TranslateY(-50%);
Left: 0px;
Right: 0px;
Z-Index: 4;
}
.Section {
Margin: 4px;
}
.NoWrap {
White-Space: NoWrap;
2022-09-07 00:20:11 +02:00
}
</style>
</head>
<body>
2022-09-07 16:13:28 +02:00
<div id="Main">
<div class="Section">
<h3>HashyMagnet</h3>
<p>Generate a full Bit<span style="Color:#AAFFFF;">Torrent</span> Magnet Link from an Info Hash!</p>
<noscript><p>
This is an actual app, not a badly-made website.
<br>
It needs JavaScript, so you need to enable it.
<br>
The code is fully open, and you can review it with "View Page Source".
</p></noscript>
</div>
<br>
<div class="Section">
<div class="NoWrap">
<button id="ResetBtn"></button>
<input id="TextBox" placeholder="📝 Paste Info Hash here...">
</div>
<div class="NoWrap">
<button id="GenerateBtn">Generate Magnet!</button>
<button id="CopyBtn">Copy link</button>
<button id="OpenBtn">Open link</button>
</div>
</div>
<br>
<div class="Section">
<div class="NoWrap">
<label for="TrackersBtn">Trackers list:</label>
<button id="TrackersBtn"></button>
</div>
<textarea id="TrackersArea" placeholder="📜 Paste Trackers here..." rows="8" cols="60"></textarea>
</div>
<br>
</div>
<div class="ocean"><div class="bubble bubble-1"></div><div class="bubble bubble-2"></div><div class="bubble bubble-3"></div><div class="bubble bubble-4"></div><div class="bubble bubble-5"></div><div class="bubble bubble-6"></div><div class="bubble bubble-7"></div><div class="bubble bubble-8"></div><div class="bubble bubble-9"></div><div class="bubble bubble-10"></div><div class="bubble bubble-11"></div></div>
2022-09-07 00:20:11 +02:00
<script>
2022-09-07 16:13:28 +02:00
var Generated = false;
2022-09-07 00:20:11 +02:00
var Trackers = [];
var TrackersNum = 35;
const TrackersSources = [
"https://ngosang.github.io/trackerslist/trackers_best.txt",
2022-09-07 16:13:28 +02:00
"https://newtrackon.com/api/stable",
2022-09-07 00:20:11 +02:00
];
2022-09-07 16:13:28 +02:00
async function FetchTrackers() {
for (let i = 0; i < TrackersSources.length; i++) {
let Req = await fetch(TrackersSources[i]);
let Data = await Req.text();
Trackers = Trackers.concat(Data.replaceAll("\n\n","\n").split("\n"));
}
Trackers = Trackers.slice(0,TrackersNum);
2022-09-07 00:20:11 +02:00
}
2022-09-07 16:13:28 +02:00
function WriteTrackers() {
for (let i = 0; i < Trackers.length; i++) {
TrackersArea.value += Trackers[i] + "\n\n";
2022-09-07 00:20:11 +02:00
}
2022-09-07 16:13:28 +02:00
DoRedraw();
}
function StoreTrackers() {
}
async function FetchWriteTrackers() {
await FetchTrackers();
WriteTrackers();
2022-09-07 00:20:11 +02:00
}
2022-09-07 16:13:28 +02:00
GenerateBtn.onclick = function() {
2022-09-07 00:20:11 +02:00
TextBox.value = "magnet:?xt=urn:btih:" + TextBox.value;
for (let i = 0; i < Trackers.length; i++) {
TextBox.value += "&tr=" + encodeURIComponent(Trackers[i]);
}
2022-09-07 16:13:28 +02:00
Generated = true;
DoRedraw();
};
function DoRedraw() {
if (Generated) {
GenerateBtn.hidden = true;
ResetBtn.hidden = false;
CopyBtn.hidden = false;
OpenBtn.hidden = false;
} else {
GenerateBtn.hidden = false;
ResetBtn.hidden = true;
CopyBtn.hidden = true;
OpenBtn.hidden = true;
}
if (TrackersArea.value) {
TrackersBtn.textContent = "🧹 Clear";
} else {
TrackersBtn.textContent = "🔄 Refresh";
}
2022-09-07 00:20:11 +02:00
}
2022-09-07 16:13:28 +02:00
ResetBtn.onclick = function() {
TextBox.value = "";
Generated = false;
DoRedraw();
};
CopyBtn.onclick = function() {
navigator.clipboard.writeText(TextBox.value);
};
OpenBtn.onclick = function() {
window.open(TextBox.value);
};
TrackersBtn.onclick = function() {
if (TrackersArea.value) {
TrackersArea.value = "";
} else {
WriteTrackers();
}
DoRedraw();
};
TrackersArea.onchange = StoreTrackers;
DoRedraw();
FetchWriteTrackers();
TrackersBtn.hidden = true;
2022-09-07 00:20:11 +02:00
</script>
</body>
</html>