mirror of
https://github.com/bellingcat/tiktok-timestamp.git
synced 2026-06-08 01:28:29 +03:00
Merge pull request #2 from Ollie-Boyd/version2
Old tool depreciated due to changes in TikTok metadata. The tool now extracts datetime from the video ID in URL.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
# tiktok-timestamp
|
# tiktok-timestamp
|
||||||
|
|
||||||
A tiny, client side tool that retrieves the timestamp from Tiktok videos. Use it on Github Pages here: https://bellingcat.github.io/tiktok-timestamp/
|
A tiny, client side tool that retrieves the timestamp from Tiktok video URLs. Works with videos that have been deleted. Use a recent Chromium based browser.
|
||||||
|
|
||||||
|
Based on research by Ryan Benson https://dfir.blog/tinkering-with-tiktok-timestamps/.
|
||||||
|
|
||||||
|
Use it on Github Pages here: https://bellingcat.github.io/tiktok-timestamp/
|
||||||
|
|||||||
71
index.html
71
index.html
@@ -1,23 +1,15 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Tiktok date extractor</title>
|
<title>Tiktok date extractor</title>
|
||||||
<script src="https://unpkg.com/dayjs"></script>
|
|
||||||
<script src="https://unpkg.com/dayjs-plugin-utc"></script>
|
|
||||||
<script>
|
|
||||||
dayjs.extend(dayjsPluginUTC.default);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
margin: 1em;
|
margin: 1em;
|
||||||
font-family: "Helvetica", Arial, sans-serif;
|
font-family: "Helvetica", Arial, sans-serif;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button, input {
|
button, input {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
@@ -25,48 +17,45 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
function getdate() {
|
function getVidId() {
|
||||||
document.getElementById("date").innerHTML = "...";
|
const tiktokUrl= document.querySelector("#url").value;
|
||||||
document.getElementById("label").innerHTML = "Uploaded on: ";
|
// This regex should be safe as "Only letters, numbers, underscores, or periods are allowed" in TikTok usernames.
|
||||||
|
const regex = /(?<=\/video\/)(.*?)(?=$|[^0-9])/;
|
||||||
|
const vidId = regex.exec(tiktokUrl)[0];
|
||||||
|
return vidId;
|
||||||
|
}
|
||||||
|
|
||||||
var url = document.getElementById("url").value;
|
function extractUnixTimestamp(vidId) {
|
||||||
|
// BigInt needed as we need to treat vidId as 64 bit decimal. This reduces browser support.
|
||||||
|
const asBinary = BigInt(vidId).toString(2);
|
||||||
|
const first31Chars = asBinary.slice(0, 31);
|
||||||
|
const timestamp = parseInt(first31Chars, 2);
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
var headers = {
|
function unixTimestampToHumanDate(timestamp) {
|
||||||
Origin: "https://www.tiktok.com",
|
const milliseconds = timestamp * 1000;
|
||||||
Accept:
|
const dateObject = new Date(milliseconds);
|
||||||
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
const humanDateFormat = dateObject.toUTCString()+" (UTC)";
|
||||||
"User-Agent":
|
return humanDateFormat;
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15",
|
}
|
||||||
"Accept-Language": "en-us",
|
|
||||||
Connection: "keep-alive",
|
|
||||||
};
|
|
||||||
|
|
||||||
resp = fetch("https://api.allorigins.win/get?url=" + encodeURIComponent(url), {
|
function getDate() {
|
||||||
method: "GET",
|
const vidId = getVidId();
|
||||||
headers: headers,
|
const unixTimestamp = extractUnixTimestamp(vidId);
|
||||||
})
|
const humanDateFormat = unixTimestampToHumanDate(unixTimestamp);
|
||||||
.then(function (r) {
|
document.querySelector("#date").textContent = humanDateFormat;
|
||||||
return r.text();
|
|
||||||
})
|
|
||||||
.then(function (text) {
|
|
||||||
text = text.replaceAll("\\", "");
|
|
||||||
var split = text.split(`"createTime":`);
|
|
||||||
split = split[1].split(`,`);
|
|
||||||
|
|
||||||
var formatted = dayjs
|
|
||||||
.utc(+split[0] * 1000)
|
|
||||||
.format("MMM D YYYY, HH:mm:ss UTC");
|
|
||||||
|
|
||||||
document.getElementById("date").innerHTML = formatted;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<label for="url">Tiktok video URL:</label>
|
<label for="url">Tiktok video URL:</label>
|
||||||
<input type="text" id="url" name="url" />
|
<input type="text" id="url" name="url" />
|
||||||
<button onclick="getdate()">Get uploaded date</button>
|
<button onclick="getDate()">Get uploaded date</button>
|
||||||
|
</div>
|
||||||
|
<div class="output">
|
||||||
|
<span id="label">Uploaded on: </span>
|
||||||
|
<span id="date"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="output"><span id="label">Uploaded on: </span><span class="date" id="date"></span></div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user