Pleroma Backup

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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)
                    }
                })
            }
        }
    }
})()