Pleroma Backup

Go to https://YOUR_INSTANCE/main/friends, F12, type in console `backupPleroma()` (without the quotes), Enter.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Pleroma Backup
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Go to https://YOUR_INSTANCE/main/friends, F12, type in console `backupPleroma()` (without the quotes), Enter.
// @author       gudzpoz
// @match        https://*/main/*
// @grant        none
// @license      AGPL-3.0-or-later
// ==/UserScript==

(function() {
    'use strict';

    function download(url) {
        console.log(url)
    }

    window.backupPleroma = () => {
        var req = indexedDB.open('localforage')
        req.onsuccess = event => {
            var db = event.target.result
            var transaction = db.transaction(['keyvaluepairs'])
            var store = transaction.objectStore('keyvaluepairs')
            var request = store.get('vuex-lz')
            request.onsuccess = event => {
                var token = request.result.oauth.userToken
                fetch('/api/v1/pleroma/backups').then(res => res.json()).then(json => {
                    if (json.length === 0 || (Date.now() - new Date(json[json.length - 1].inserted_at)) / 1000 / 60 / 60 / 24 > 7) {
                        fetch('/api/v1/pleroma/backups', {
                            method: 'POST',
                            headers: {
                                'Authorization': `Bearer ${token}`,
                            },
                        }).then(res => res.json()).then(archive => {
                            download(archive[archive.length - 1].url)
                        })
                    } else {
                        download(json[json.length - 1].url)
                    }
                })
            }
        }
    }
})()