-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OPML for RSS Readers #841
Comments
This is an example if you want to make the file downloadable when using the script. function generateOPML() {
/*
<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
<head>
<title>Liferea Feed List Export</title>
</head>
<body>
<outline title="TITLE" text="TITLE" description="TITLE" type="folder">
<outline title="TITLE" text="TITLE" description="TITLE" type="rss" xmlUrl="URL"/>
</outline>
</body>
</opml>
*/
document
.querySelector('#opml-selection')
.addEventListener ('click', function() {
var opmlData = document.implementation.createDocument(null, "opml", null);
opmlData.getElementsByTagName("opml")[0].setAttribute("version", "1.0");
var text = opmlData.createTextNode("Newspaper Feed Selection");
let name = opmlData.createElement("title")
let head = opmlData.createElement("head")
let body = opmlData.createElement("body");
let sections = document.querySelectorAll('#feeds .content .category');
for (const section of sections) {
let title = section.querySelector('h3').outerText;
let category = opmlData.createElement("outline");
category.setAttribute("title", title);
category.setAttribute("text", title);
category.setAttribute("text", title);
category.setAttribute("type", "folder");
// TODO Handle subcategories
let links = section.querySelectorAll('a');
for (const link of links) {
let feed = opmlData.createElement("outline");
let title = link.outerText;
let url = link.href;
feed.setAttribute("title", title);
feed.setAttribute("text", title);
feed.setAttribute("text", title);
// NOTE This value (rss) is arbitrary.
// TODO Add type to class.
//feed.setAttribute("type", "rss");
feed.setAttribute("xmlUrl", url);
category.appendChild(feed);
}
body.appendChild(category);
}
head.appendChild(name);
name.appendChild(text);
opmlData.getElementsByTagName("opml")[0].appendChild(head);
opmlData.getElementsByTagName("opml")[0].appendChild(body);
var opmlFile = new XMLSerializer().serializeToString(opmlData);
savePage(
opmlFile,
'i2p-schimon-newspaper',
'text/x-opml+xml',
'opml'
)
});
}
// export file
// /questions/4545311/download-a-file-by-jquery-ajax
// /questions/43135852/javascript-export-to-text-file
var savePage = (function () {
var a = document.createElement("a");
// document.body.appendChild(a);
// a.style = "display: none";
return function (fileData, fileName, fileType, fileExtension) {
var blob = new Blob([fileData], {type: fileType}),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName + '.' + fileExtension;
a.click();
window.URL.revokeObjectURL(url);
};
}()); I've extracted this from https://greasyfork.org/en/scripts/465932-newspaper-native-rss-reader |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest to add both, opml file (when js is disabled) and js script (when js is enabled).
Code
Format
xmllint FILE.txt --format > xxiivv_webring.opml
Result
The text was updated successfully, but these errors were encountered: