© 2024 borui. All rights reserved.
This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article:
borui(2024-01-27 02:12:26 +0000). how to extract chrome bookmark added date. https://borui/blog/2024-01-27-en-chrome-bookmark-added-date.
@misc{
borui2024,
author = {borui},
title = {how to extract chrome bookmark added date},
year = {2024},
publisher = {borui's blog},
journal = {borui's blog},
url={https://borui/blog/2024-01-27-en-chrome-bookmark-added-date}
}
introduction
Because I am writing notes on what I have learned before recently, I find it useful if I can view broswers bookmarks and history so that I can review related history and bookmarks more effciently.
While history in chrome has date displayed and sorted out, the bookmarks doesn't.
finding solutions
plugins
While I have found plugins but I don't trust plugins since I am so paranoid.
tracing the source
I learned that the Bookmarks file in your profile directory has the attribute "date_added", which is a timestamp.
Then I have to locate this file.
I have learned that in a windows machine(which I use now).
The file located at Chrome user data folder (i.e. Users/[Username]/AppData/Local/Google/Chrome/User Data/Default
)
- @taipou. (2017, Janurary 22). Yes. Open the Bookmarks file in your profile directory, locate the bookmark in question and see the "date_added". Then convert the timestamp to time&date. [Comment]. Reddit. https://www.reddit.com/r/chrome/comments/5p94sr/is_there_a_way_to_see_what_date_i_added_a_bookmark/
- Vineeth Kumar Marupadige. (2017, Janurary 22). Most likely, the problem will be solved by this Search for "bookmarks.bak" in Windows Explorer Right-click the file and choose "Open file location" to open the folder, which should be your Chrome user data folder (i.e., Users/[Username]/AppData/Local/Google/Chrome/User Data/Default) Open the bookmarks backup file in Notepad. Your old bookmarks, hopefully, are listed there In Chrome, go to Settings > Advanced sync settings (under the Sign in section) and change the sync settings so that Bookmarks aren't synced, if they currently are set to sync Close Chrome Back in the Chrome user data folder, find another "Bookmarks" file without an extension. Rename it "Bookmarks2.bak" Then rename the "Bookmarks.bak" file to "Bookmarks" [Answer]. Quora. https://www.quora.com/How-can-I-find-my-bookmarks-if-they-have-disappeared-from-Chrome/answer/Vineeth-Kumar-Marupadige-%E0%B0%B5%E0%B0%BF%E0%B0%A8%E0%B1%80%E0%B0%A4%E0%B1%8D-%E0%B0%95%E0%B1%81%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D-%E0%B0%AE%E0%B0%B0%E0%B1%81%E0%B0%AA%E0%B0%A1%E0%B0%BF%E0%B0%97%E0%B1%86
taking look at the files
The file is a json document. High level view is below:
{
"checksum": "c2d3fb04563b236510147df664bcc150",
"roots": {
"bookmark_bar":{
// ...
},
"others":{
// ...
}
}
}
bookmark_bar, others are all displaped as folders in chrome. Then let's take a look at inside of one of the folders. We can see it not only has date_added but also date_last_used.
{
"checksum": "c2d3fb04563b236510147df664bcc150",
"roots": {
"bookmark_bar":{
"children": [ {
"date_added": "13290325579000000",
"date_last_used": "0",
"guid": "8b486269-2f6f-4676-a5c0-dd42dc88c538",
"id": "31",
"name": "How to Create a PWA With Next.js - DEV Community",
"type": "url",
"url": "https://dev.to/byteslash/how-to-create-a-pwa-with-next-js-4dbm"
}, {
"date_added": "13290811720000000",
"date_last_used": "0",
"guid": "681b9a2a-7c63-473f-a2e1-1095f766782c",
"id": "38",
"name": "HackerRank",
"type": "url",
"url": "https://www.hackerrank.com/"
}, {
"date_added": "13290858633000000",
"date_last_used": "0",
"guid": "372baa03-132c-4853-a46b-1409aa70c127",
"id": "39",
"name": "How to Bundle a Simple Static Site Using Webpack - SitePoint",
"type": "url",
"url": "https://www.sitepoint.com/bundle-static-site-webpack/"
}, {
"date_added": "13291416359000000",
"date_last_used": "0",
"guid": "258fbb34-8df3-41ee-8753-4276f978d8e5",
"id": "40",
"name": "seq command in Linux with Examples - GeeksforGeeks",
"type": "url",
"url": "https://www.geeksforgeeks.org/seq-command-in-linux-with-examples/"
}, {
"date_added": "13291425628000000",
"date_last_used": "0",
"guid": "8e4c9491-8a6b-4e60-bc61-758aad1b88ce",
"id": "41",
"name": "What does \"esac\" mean at the end of a bash case statement? Is it required? - Unix & Linux Stack Exchange",
"type": "url",
"url": "https://unix.stackexchange.com/questions/256149/what-does-esac-mean-at-the-end-of-a-bash-case-statement-is-it-required"
}, {
"date_added": "13291426538000000",
"date_last_used": "0",
"guid": "bb1275b3-f747-4a14-8956-e84bdedffe85",
"id": "42",
"name": "Functions and Fractals - Recursive Trees - Bash! Discussions | Linux Shell | HackerRank",
"type": "url",
"url": "https://www.hackerrank.com/challenges/fractal-trees-all/forum/comments/469102"
}, {
"date_added": "13291569746000000",
"date_last_used": "0",
"guid": "e0a5874e-ced0-4899-bb41-df3bee8b9f02",
"id": "43",
"name": "Time Complexities of all Sorting Algorithms - GeeksforGeeks",
"type": "url",
"url": "https://www.geeksforgeeks.org/time-complexities-of-all-sorting-algorithms/"
}, {
"date_added": "13291868121000000",
"date_last_used": "0",
"guid": "08b8233f-5ad3-4f35-9fdf-533e39917c7b",
"id": "49",
"name": "Unix / Linux - Regular Expressions with SED",
"type": "url",
"url": "https://www.tutorialspoint.com/unix/unix-regular-expressions.htm"
}
"children": [
{
// can have nested child folder
}
]
]
},
"others":{
// ...
}
}
}
parsing the file use js
unfolding nested contents
according to the structure of the json document, we can easily identify the recursive nature of the children attribute(essentially the parent nodes in the tree). Write a recursive function to flatten the tree structure document to a list is trivial.
"children": [
"children":[
"children":[
{
//obj
"name": "Unix / Linux - Regular Expressions with SED",
}
]
],
{
//obj
"name": "Time Complexities of all Sorting Algorithms - GeeksforGeeks",
}
]
// unfolding nested bookmarks to a list
function children_to_list(chd){
var list = [];
for(var i in chd){
//terminal condition
if(chd[i].children){
//recursive call
list = list.concat(children_to_list(chd[i].children));
} else {
list.push(chd[i]);
}
}
return list;
}
Let's test the correctness of the code.
l = children_to_list(bookmarks.roots.other.children)
console.log(l[0],l[1],l[l.length-1], l.length)
for(let i of l){
if(i.name){
console.log(i.name)
}else{
console.log("wrong type")
break
}
}
Output should be something like this:
{
date_added: '0',
date_last_used: '0',
guid: 'b36223e0-8f0d-faf7-b97b-eef5ae01cf3e',
id: '110',
name: '114网站导航www.114.com.cn',
type: 'url',
url: 'http://www.114.com.cn/tindex.html'
} {
date_added: '0',
date_last_used: '0',
guid: '7fb44715-7ae7-fbd6-aeba-4b04999d69d0',
id: '111',
name: 'DirectX10',
type: 'url',
url: 'http://www.lwgame.net/'
} {
date_added: '13350832066016505',
date_last_used: '0',
guid: '3b456bc4-a639-4a00-a9f2-0b1ef4dc0ba3',
id: '411',
meta_info: { power_bookmark_meta: '' },
name: 'markdown中插入图片怎么定义图片的大小或比例? - 知乎',
type: 'url',
url: 'https://www.zhihu.com/question/23378396'
} 237
114网站导航www.114.com.cn
DirectX10
MA
Microsoft 商店
Internet Explorer 8:主页
Marketplace
Microsoft 家庭安全
change date_added to readable format
I have tried bkmk.date_added = new Date(bkmk.date_added);
and then found out that the result is invalid.
This is because google use a different definition of timestamp.(really can't relate to it)
Below code is a quote from an answer on stackoverflow
The Chrome bookmarks time value is microseconds from an epoch of 1601-01-01T00:00:00Z. To convert to a Date:
Divide by 1,000 to get milliseconds Adjust to an epoch of 1970-01-01T00:00:00Z Pass the resulting value to the Date constructor E.g.
var timeValue = '13170147422089597';
new Date(Date.UTC(1601,0,1) + timeValue / 1000); // 2018-05-07T06:17:02.089Z
Storing the value Date.UTC(1601,0,1) as a constant (-11644473600000) and converting to a function gives:
function chromeTimeValueToDate(tv) {
var epoch = -11644473600000;
return new Date(epoch + tv / 1000);
}
// Example
['13170147422089597',
'13150297844686316',
'13115171381595644'].forEach( tv => {
console.log(chromeTimeValueToDate(tv))
});
- RobG. [@RobG]. (July 14, 2018). The Chrome bookmarks time value is microseconds from an epoch of 1601-01-01T00:00:00Z. To convert to a Date:. [Answer]. stackoverflow. https://stackoverflow.com/questions/51343828/how-to-parse-chrome-bookmarks-date-added-value-to-a-date/51343829#51343829
Below is the code I wrote according to robG's answer to output bookmark sorted by date.
//sort l by date_added
l.sort((a,b) => a.date_added - b.date_added)
// l[0].date_added = new Date(l[0].date_added)
function timestamp_to_readable(bkmk){
bkmk.date_added = new Date(Date.UTC(1601,0,1) + bkmk.date_added / 1000);
return bkmk;
}
l = l.map(timestamp_to_readable)
console.log(l[0],l[1],l[l.length-1], l.length)
for(let i of l){
if(i.name){
console.log(i.date_added, i.name)
}else{
console.log("wrong type")
break
}
}
Output is correct:
2024-01-24T09:40:00.168Z Using readable streams - Web APIs | MDN
2024-01-24T09:49:44.741Z javascript - html download attribute redirects to url instead of downloading - Stack Overflow
2024-01-24T09:49:48.176Z <a>: The Anchor element - HTML: HyperText Markup Language | MDN
2024-01-26T12:10:53.341Z ZIP格式分析 | Lordaeron_ESZ's blog
2024-01-27T10:24:02.656Z 19 Markdown 注释_Markdown 入门教程-慕课网
2024-01-27T10:57:46.250Z Visual Studio Code多行同时输入_visual studio 上下一起输入-CSDN博客
2024-01-27T12:14:51.998Z Promise.all() - JavaScript | MDN
last edited 2024 March 2nd 02:12:26 +0000