Open markyun opened 2 hours ago
浏览器 f12 控制台
function listFeeds() {
return new Promise((resolve, reject) => {
const request = indexedDB.open("FOLLOW_DB", 50);
request.onsuccess = function(event) {
const db = event.target.result;
console.log("数据库打开成功");
const transaction = db.transaction(["feeds"]);
const objectStore = transaction.objectStore("feeds");
const cursorRequest = objectStore.openCursor();
const results = []; // 用于存储查询结果的数组
cursorRequest.onsuccess = function(event) {
const cursor = event.target.result;
if (cursor) {
results.push(cursor.value); // 将当前记录推入数组
cursor.continue(); // 继续遍历下一个记录
} else {
resolve(results); // 查询完成,返回结果
}
};
cursorRequest.onerror = function(event) {
reject("查询失败: " + event.target.error); // 查询失败,返回错误
};
};
request.onerror = function(event) {
reject("数据库打开失败: " + event.target.error); // 数据库打开失败,返回错误
};
request.onupgradeneeded = function(event) {
// 这里可以处理数据库升级逻辑
};
});
}
function jsonToOpml(jsonData) {
let opml = `<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
<head>
<title>Feed List</title>
</head>
<body>`;
jsonData.forEach(feed => {
opml += `
<outline
type="${feed.type || 'feed'}"
text="${feed.title || ''}"
title="${feed.title || ''}"
xmlUrl="${feed.url || ''}"
htmlUrl="${feed.siteUrl || ''}"
description="${feed.description || ''}">
</outline>`;
});
opml += `
</body>
</opml>`;
return opml;
}
function downloadOpml(opml, filename = 'feeds.opml') {
const blob = new Blob([opml], { type: 'application/xml' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url); // 释放对象 URL
}
downloadOpml(jsonToOpml(await listFeeds()))
回车导出
浏览器 f12 控制台
function listFeeds() { return new Promise((resolve, reject) => { const request = indexedDB.open("FOLLOW_DB", 50); request.onsuccess = function(event) { const db = event.target.result; console.log("数据库打开成功"); const transaction = db.transaction(["feeds"]); const objectStore = transaction.objectStore("feeds"); const cursorRequest = objectStore.openCursor(); const results = []; // 用于存储查询结果的数组 cursorRequest.onsuccess = function(event) { const cursor = event.target.result; if (cursor) { results.push(cursor.value); // 将当前记录推入数组 cursor.continue(); // 继续遍历下一个记录 } else { resolve(results); // 查询完成,返回结果 } }; cursorRequest.onerror = function(event) { reject("查询失败: " + event.target.error); // 查询失败,返回错误 }; }; request.onerror = function(event) { reject("数据库打开失败: " + event.target.error); // 数据库打开失败,返回错误 }; request.onupgradeneeded = function(event) { // 这里可以处理数据库升级逻辑 }; }); } function jsonToOpml(jsonData) { let opml = `<?xml version="1.0" encoding="UTF-8"?> <opml version="2.0"> <head> <title>Feed List</title> </head> <body>`; jsonData.forEach(feed => { opml += ` <outline type="${feed.type || 'feed'}" text="${feed.title || ''}" title="${feed.title || ''}" xmlUrl="${feed.url || ''}" htmlUrl="${feed.siteUrl || ''}" description="${feed.description || ''}"> </outline>`; }); opml += ` </body> </opml>`; return opml; } function downloadOpml(opml, filename = 'feeds.opml') { const blob = new Blob([opml], { type: 'application/xml' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); // 释放对象 URL } downloadOpml(jsonToOpml(await listFeeds()))
回车导出
good job
官方的(但目前似乎有些小问题,没有导出自定义title):https://api.follow.is/subscriptions/export
Clear and concise description of the problem
Suggested solution
建议加上 订阅源的导出能力。
Alternative
No response
Additional context
No response
Validations