Skip to content
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

Open
sjehuda opened this issue Nov 21, 2023 · 1 comment
Open

OPML for RSS Readers #841

sjehuda opened this issue Nov 21, 2023 · 1 comment

Comments

@sjehuda
Copy link

sjehuda commented Nov 21, 2023

I suggest to add both, opml file (when js is disabled) and js script (when js is enabled).

Code

// Generate OPML from webring.xxiivv.com
var opmlData = document.implementation.createDocument(null, "opml", null);
opmlData.getElementsByTagName("opml")[0].setAttribute("version", "1.0");
var text = opmlData.createTextNode("webring.xxiivv.com");
let name = opmlData.createElement("title")
let head = opmlData.createElement("head")
let body = opmlData.createElement("body");
let links = document.querySelectorAll('ol > li');
for (const link of links) {
  if (link.querySelector('.rss')) {
    let feed = opmlData.createElement("outline");
    let title = link.outerText.replace(" rss","")
    let url = link.querySelector('.rss').href;
    feed.setAttribute("title", title);
    feed.setAttribute("text", title);
    feed.setAttribute("xmlUrl", url);
    body.appendChild(feed);
  }
}
head.appendChild(name);
name.appendChild(text);
opmlData.getElementsByTagName("opml")[0].appendChild(head);
opmlData.getElementsByTagName("opml")[0].appendChild(body);
var opmlFile = new XMLSerializer().serializeToString(opmlData);
console.info(opmlFile)

Format

xmllint FILE.txt --format > xxiivv_webring.opml

Result

<?xml version="1.0"?>
<opml version="1.0">
  <head>
    <title>webring.xxiivv.com</title>
  </head>
  <body>
    <outline title="xxiivv" text="xxiivv" xmlUrl="https://wiki.xxiivv.com/links/rss.xml"/>
    <outline title="electro pizza" text="electro pizza" xmlUrl="https://electro.pizza/feed.xml"/>
    <outline title="detritus.zone" text="detritus.zone" xmlUrl="https://detritus.zone/feed.xml"/>
    <outline title="heracl.es" text="heracl.es" xmlUrl="https://heracl.es/feed.xml"/>
    <outline title="lectronice" text="lectronice" xmlUrl="https://now.lectronice.com/feed.xml"/>
    <outline title="cblgh" text="cblgh" xmlUrl="https://cblgh.org/all.xml"/>
    <outline title="ellugar" text="ellugar" xmlUrl="http://feeds.ellugar.co/ellugar-logs"/>
    <outline title="longest.voyage" text="longest.voyage" xmlUrl="https://longest.voyage/index.xml"/>
    <outline title="palomakop.tv" text="palomakop.tv" xmlUrl="https://palomakop.tv/rss.xml"/>
    <outline title="kokorobot.ca" text="kokorobot.ca" xmlUrl="https://kokorobot.ca/links/rss.xml"/>
    <outline title="ameyama" text="ameyama" xmlUrl="https://ameyama.com/blog/rss.xml"/>
    <outline title="nonmateria" text="nonmateria" xmlUrl="http://nonmateria.com/rss.xml"/>
    <outline title="chad.is" text="chad.is" xmlUrl="https://chad.is/rss.xml"/>
    <outline title="ritual dust" text="ritual dust" xmlUrl="https://ritualdust.com/index.xml"/>
    <outline title="szymonkaliski" text="szymonkaliski" xmlUrl="https://szymonkaliski.com/feed.xml"/>
    <outline title="phse.net" text="phse.net" xmlUrl="https://phse.net/post/index.xml"/>
    <outline title="rosano.ca" text="rosano.ca" xmlUrl="https://rosano.ca/feed"/>
    <outline title="serocell.com" text="serocell.com" xmlUrl="https://serocell.com/feeds/serocell.xml"/>
    <outline title="eli.li" text="eli.li" xmlUrl="https://eli.li/feed.rss"/>
    <outline title="gosha.net" text="gosha.net" xmlUrl="https://gosha.net/feed.xml"/>
    <outline title="oddworlds soliloquy" text="oddworlds soliloquy" xmlUrl="https://oddworlds.org/rss.xml"/>
    <outline title="resevoir" text="resevoir" xmlUrl="https://resevoir.net/rss.xml"/>
    <outline title="0xdstn" text="0xdstn" xmlUrl="https://tilde.town/~dustin/index.xml"/>
    <outline title="James Chip" text="James Chip" xmlUrl="https://jameschip.io/index.xml"/>
    <outline title="icyphox.sh" text="icyphox.sh" xmlUrl="https://icyphox.sh/blog/feed.xml"/>
    <outline title="Cr;Lf;" text="Cr;Lf;" xmlUrl="https://crlf.link/feed.xml"/>
    <outline title="Nat Welch" text="Nat Welch" xmlUrl="https://writing.natwelch.com/feed.rss"/>
    <outline title="Simone's Computer" text="Simone's Computer" xmlUrl="https://system31.simone.computer/rss.xml"/>
    <outline title="dreamspace" text="dreamspace" xmlUrl="http://xj-ix.luxe/feed.atom"/>
    <outline title="q.pfiffer.org" text="q.pfiffer.org" xmlUrl="http://q.pfiffer.org/feed.xml"/>
    <outline title="Archive Fever" text="Archive Fever" xmlUrl="https://www.edwinwenink.xyz/index.xml"/>
    <outline title="roytang.net" text="roytang.net" xmlUrl="https://roytang.net/index.xml"/>
    <outline title="MaterialFuture" text="MaterialFuture" xmlUrl="https://www.materialfuture.net/rss.xml"/>
    <outline title="Dampfkraft" text="Dampfkraft" xmlUrl="https://dampfkraft.com/index.rss"/>
    <outline title="travisshears" text="travisshears" xmlUrl="https://travisshears.com/index.xml"/>
    <outline title="yctct" text="yctct" xmlUrl="https://www.yctct.com/feed.rss"/>
    <outline title="Felix Elsner" text="Felix Elsner" xmlUrl="https://ix5.org/thoughts/feeds/all.atom.xml"/>
    <outline title="Julien Desrosiers" text="Julien Desrosiers" xmlUrl="https://www.juliendesrosiers.com/feed.xml"/>
    <outline title="nchrs.xyz" text="nchrs.xyz" xmlUrl="https://nchrs.xyz/links/rss.xml"/>
    <outline title="Northern Information" text="Northern Information" xmlUrl="https://nor.the-rn.info/feed.xml"/>
    <outline title="Matilde Park" text="Matilde Park" xmlUrl="https://matildepark.ca/feed.xml"/>
    <outline title="inqlab.net" text="inqlab.net" xmlUrl="https://inqlab.net/posts.xml"/>
    <outline title="metasyn" text="metasyn" xmlUrl="https://metasyn.pw/rss.xml"/>
    <outline title="neeasade" text="neeasade" xmlUrl="https://notes.neeasade.net/rss.xml"/>
    <outline title="wesleyac" text="wesleyac" xmlUrl="https://notebook.wesleyac.com/atom.xml"/>
    <outline title="wolfmd" text="wolfmd" xmlUrl="https://wolfmd.me/feed.xml"/>
    <outline title="corvid cafe" text="corvid cafe" xmlUrl="https://corvid.cafe/feed.xml"/>
    <outline title="anti-pattern / alessia bellisario" text="anti-pattern / alessia bellisario" xmlUrl="https://aless.co/rss.xml"/>
    <outline title="mrshll" text="mrshll" xmlUrl="https://mrshll.com/feed.rss"/>
    <outline title="hs0ucy" text="hs0ucy" xmlUrl="https://hugo.soucy.cc/index.xml"/>
    <outline title="darch" text="darch" xmlUrl="https://darch.dk/feed/page:feed.xml"/>
    <outline title="notebook.hew.tt" text="notebook.hew.tt" xmlUrl="https://notebook.hew.tt/index.xml"/>
    <outline title="gr0k" text="gr0k" xmlUrl="https://www.gr0k.net/blog/feed.xml"/>
    <outline title="Ten Digits" text="Ten Digits" xmlUrl="https://tendigits.space/feed.xml"/>
    <outline title=" itwont.work " text=" itwont.work " xmlUrl="https://itwont.work/atom.xml"/>
    <outline title="pixouls" text="pixouls" xmlUrl="https://www.pixouls.xyz/rss.xml"/>
    <outline title="embyr.sh" text="embyr.sh" xmlUrl="https://embyr.sh/index.xml"/>
    <outline title="compudanzas" text="compudanzas" xmlUrl="https://compudanzas.net/atom.xml"/>
    <outline title="astral&#x2194;bijection" text="astral&#x2194;bijection" xmlUrl="https://astrid.tech/atom.xml"/>
    <outline title="flower.codes" text="flower.codes" xmlUrl="http://flower.codes/feed.xml"/>
    <outline title="paritybit.ca" text="paritybit.ca" xmlUrl="https://www.paritybit.ca/feed.xml"/>
    <outline title="Ferale Art" text="Ferale Art" xmlUrl="https://ferale.art/feed"/>
    <outline title="Well Observe" text="Well Observe" xmlUrl="https://www.wellobserve.com/index.php?rss=en"/>
    <outline title="D00k" text="D00k" xmlUrl="https://d00k.net/index.xml"/>
    <outline title="Helvetica Blanc" text="Helvetica Blanc" xmlUrl="https://helveticablanc.com/feed.xml"/>
    <outline title="armaina" text="armaina" xmlUrl="http://armaina.com/rss.xml"/>
    <outline title="aphrodite.dev" text="aphrodite.dev" xmlUrl="https://www.aphrodite.dev/~blog/feed.xml"/>
    <outline title="kae.si" text="kae.si" xmlUrl="https://kae.si/feed.xml"/>
    <outline title="Erin Bern" text="Erin Bern" xmlUrl="https://erinbern.com/feed"/>
    <outline title="ch&#xF6;trin's wiki." text="ch&#xF6;trin's wiki." xmlUrl="https://chotrin.org/rss.xml"/>
    <outline title="vitbaisa" text="vitbaisa" xmlUrl="https://vit.baisa.cz/index.xml"/>
    <outline title="bloguslibrus" text="bloguslibrus" xmlUrl="https://www.bloguslibrus.fr/atom.xml"/>
    <outline title="strickinato" text="strickinato" xmlUrl="https://aaronstrick.com/rss.xml"/>
    <outline title="Sweetfish Ayu" text="Sweetfish Ayu" xmlUrl="https://ayu.land/rss.en.xml"/>
    <outline title="tosatur" text="tosatur" xmlUrl="https://tosatur.com/notes/rss.xml"/>
    <outline title="pfych" text="pfych" xmlUrl="https://pfy.ch/rss.xml"/>
    <outline title="benji" text="benji" xmlUrl="https://benji.dog/feed.xml"/>
    <outline title="manifoldslug" text="manifoldslug" xmlUrl="http://wreckage.link/rss.xml"/>
    <outline title="louisload" text="louisload" xmlUrl="https://luis.zip/blog/index.xml"/>
    <outline title="foreverliketh.is" text="foreverliketh.is" xmlUrl="https://foreverliketh.is/blog/index.xml"/>
    <outline title="ratfactor" text="ratfactor" xmlUrl="http://ratfactor.com/atom.xml"/>
    <outline title="squid" text="squid" xmlUrl="https://hideout.ink/"/>
  </body>
</opml>
@sjehuda
Copy link
Author

sjehuda commented Nov 21, 2023

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant