<template>
  <div class="popup">
    <div v-if="feedUrl">
      <a :href="feedUrl" target="_blank">Found a feed URL</a>
    </div>
    <div v-else>
      No feed URLs found on this page
    </div>
  </div>
</template>

<script>
import browser from 'webextension-polyfill';

export default {
  name: 'Popup',
  data() {
    return {
      feedUrl: null,
    }
  },

  async mounted() {
    const [tab] = await browser.tabs.query({ active: true, currentWindow: true })
    this.feedUrl = await browser.tabs.sendMessage(tab.id, {type: 'extractFeedUrl'})
  },
}
</script>

<style scoped>
.popup {
  padding: 1em;
}
</style>
