<commit_before><style type="text/css" media="screen">
#container {
  width: 240px;
  font-family: sans-serif;
}

ul.menu {
  font-size: 16px;
  list-style: none;
  padding: 0 0.5em;
}

ul.menu > li {
  border: 1px solid black;
  padding: 5px;
  border-radius: 5px;
  margin-top: 3px;
  margin-bottom: 3px;
  cursor: pointer;
}

ul.menu > li.hover {
  background-color: #FCC;
}

h1 {
  font-size: 18px;
}

#result textarea {
  width: 100%;
}

</style>

<div id="container">
  <div id="result">
    <textarea id="result-markdown" readonly="readonly"></textarea>
  </div>
  <div id="current-tab">
    <h1>Current Tab</h1>
    <ul class="menu">
      <li id="current-tab-link"><code>[title](url)</code></li>
      <li id="current-tab-link-with-identifier"><code>[title][<em>identifier</em>]</code></li>
    </ul>
  </div>

  <div id="all-tabs">
    <h1>All Tabs as List</h1>
    <ul class="menu">
      <li id="all-tabs-link-as-list"><code>* [title](url)</code></li>
    </ul>
  </div>
</div>

<script type="text/javascript">
(function() {

  var resultContainer = document.getElementById("result-markdown");
  resultContainer.addEventListener("click", function() {
    resultContainer.select();
  });

  document.getElementById("current-tab-link").addEventListener("click", function() {
    chrome.tabs.getSelected(null, function(tab) {
      chrome.extension.sendRequest({
        action: "copyLinkAsMarkdown",
        params: {
          title: tab.title,
          url: tab.url,
          options: {
            use_identifier: false
          }
        }
      }, function(response) {
        resultContainer.value = response.markdown;
        console.log(response);
      });
    });
  });

  document.getElementById("current-tab-link-with-identifier").addEventListener("click", function() {
    chrome.tabs.getSelected(null, function(tab) {
      chrome.extension.sendRequest({
        action: "copyLinkAsMarkdown",
        params: {
          title: tab.title,
          url: tab.url,
          options: {
            use_identifier: true
          }
        }
      }, function(response) {
        resultContainer.value = response.markdown;<commit_msg>Implement "Get Current Tab of Current Window" by chrome.tabs.query()<commit_after><style type="text/css" media="screen">
#container {
  width: 240px;
  font-family: sans-serif;
}

ul.menu {
  font-size: 16px;
  list-style: none;
  padding: 0 0.5em;
}

ul.menu > li {
  border: 1px solid black;
  padding: 5px;
  border-radius: 5px;
  margin-top: 3px;
  margin-bottom: 3px;
  cursor: pointer;
}

ul.menu > li.hover {
  background-color: #FCC;
}

h1 {
  font-size: 18px;
}

#result textarea {
  width: 100%;
}

</style>

<div id="container">
  <div id="result">
    <textarea id="result-markdown" readonly="readonly"></textarea>
  </div>
  <div id="current-tab">
    <h1>Current Tab</h1>
    <ul class="menu">
      <li id="current-tab-link"><code>[title](url)</code></li>
      <li id="current-tab-link-with-identifier"><code>[title][<em>identifier</em>]</code></li>
    </ul>
  </div>

  <div id="all-tabs">
    <h1>All Tabs as List</h1>
    <ul class="menu">
      <li id="all-tabs-link-as-list"><code>* [title](url)</code></li>
    </ul>
  </div>
</div>

<script type="text/javascript">
(function() {

  var resultContainer = document.getElementById("result-markdown");
  resultContainer.addEventListener("click", function() {
    resultContainer.select();
  });

  var getCurrentTab = function (callback) {
    chrome.tabs.query({
      windowId: chrome.windows.WINDOW_ID_CURRENT,
      active: true
    }, function(tabs) {
      callback(tabs[0]);
    });
  };

  document.getElementById("current-tab-link").addEventListener("click", function() {
    getCurrentTab(function(tab) {
      chrome.extension.sendRequest({
        action: "copyLinkAsMarkdown",
        params: {
          title: tab.title,
          url: tab.url,
          options: {
            use_identifier: false
          }
        }
      }, function(response) {
        resultContainer.value = response.markdown;
        console.log(response);
      });
    });
  });

  document.getElementById("current-tab-link-with-identifier").addEventListener("click", function() {
    getCurrentTab(function(tab) {
      chrome.extension.sendRequest({
        action: "copyLinkAsMarkdown",
        params: {
          title: tab.title,
          url: tab.url,
          options: {
            use_identifier: true
          }
        }
      }, function(response) {
        resultContainer.value = response.markdown;
{'fraction_non_alphanumeric': 0.16751157152303284, 'fraction_numerical': 0.010359268238924399, 'mean_word_length': 2.772236076475478, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5253689', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1464, 'n_words': 264}