/*
* @title bookmarklet
* @description my bookmarklet
* @include http://*
* @license MIT License
* @require
* @private
*/
// BUG: TIMELINE_REFRESH_SUCCESS always *concat* to cached timeline...
((
store = (() => {
// >= v16: to descendant
let current_node = document.querySelector('#mastodon')._reactRootContainer.current.child;
while ('function' === typeof current_node.type) {
const store = current_node.memoizedProps.store;
if (store) return store;
current_node = current_node.child;
}
})(),
now = new Date(),
now_array = [0, now.getFullYear(), now.getMonth() + 1, now.getDate(), now.getHours(), now.getMinutes()],
query = String(prompt('Enter max_id:\n [[yyyy/]mm/dd ]hh:mm or status_id\nLeave empty to load latest timeline.')),
query_date = query && query.match(/(?:(?:(\d{4})\D+)?(\d+)\D+(\d+)\D+)?(\d+):(\d+)/).map((e, i) => e || now_array[i]),
max_id = query_date ? new Date(query_date[1], query_date[2] - 1, query_date[3], query_date[4], query_date[5], 0).getTime() * 2 ** 16 : query
) =>
fetch(`/api/v1/timelines/public?local=true${ max_id ? '&max_id=' + max_id : ''}`)
.then(x => x.json())
.then(x => store.dispatch({
type: 'TIMELINE_REFRESH_SUCCESS',
timeline: 'community',
statuses: x,
partial: false
}))
)();