Skip to content

Latest commit

 

History

History
290 lines (264 loc) · 10.8 KB

File metadata and controls

290 lines (264 loc) · 10.8 KB

Plan

Further check the menu :org-roam-capture-extension:

  • State “DONE” from “TODO” [2024-10-23 Wed 16:04]
[2024-10-21 Mon 09:59] In file: background.js
browser.menus.create(
    {
        id: \"org-capture-selection\",
        title: \"Capture Selection\",
        contexts: [\"selection\"],
        documentUrlPatterns: [\"<all_urls>\"],  // \"https://*\" not works...
        icons: {
            \"16\": \"img/icon16.png\",
            \"32\": \"img/icon32.png\"
        }
    },
    () => {
        if (browser.runtime.lastError)
            console.log(`Error: ${browser.runtime.lastError}`)
    }
)


browser.menus.onClicked.addListener((info, tab) => {
    if (info.menuItemId === \"org-capture-selection\") {
        // console.log(info.selectionText);
        runScripts();
    }
});

Replace turndown with readability

  • State “DONE” from “WORKING” [2024-10-22 Tue 09:54]
  • State “WORKING” from “TODO” [2024-10-22 Tue 09:26]
https://github.com/mozilla/readability

Check the popup func

  • State “DONE” from “WORKING” [2024-10-21 Mon 16:54]
  • State “WORKING” from “TODO” [2024-10-21 Mon 13:24]

Does api summarize requires the listener :org-roam-capture-extension:

  • State “DONE” from “HOLD” [2024-10-21 Mon 10:09]
  • State “HOLD” from “WORKING” [2024-10-21 Mon 10:08]
  • State “WORKING” from “TODO” [2024-10-21 Mon 10:05]
[2024-10-21 Mon 10:04] In file: background.js
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  if (request.action === \"summarizeContent\") {

Not sure…

Setup the background listener :org-roam-capture-extension:

  • State “DONE” from “HOLD” [2024-10-22 Tue 15:06]
  • State “HOLD” from “WORKING” [2024-10-22 Tue 13:47]
  • State “WORKING” from “TODO” [2024-10-22 Tue 13:27]
[2024-10-22 Tue 09:56] In file: capture.js

Setup the popup.js and popup.html :org-roam-capture-extension:

  • State “DONE” from “TODO” [2024-10-22 Tue 13:45]
[2024-10-22 Tue 09:57] In file: capture.js

Check the openai api :org-roam-capture-extension:

  • State “DONE” from “WORKING” [2024-10-22 Tue 10:57]
  • State “WORKING” from “TODO” [2024-10-22 Tue 10:47]
[2024-10-22 Tue 10:46] In file: background.js
fetch(apiUrl, {
    method: \"POST\",
    headers: {
        \"Content-Type\": \"application/json\",
        Authorization: `Bearer ${apiKey}`,
    },
    body: JSON.stringify({
        model: model,
        prompt: prompt,
    }),
})

[#A] See how to setup the popup page :org-roam-capture-extension:

  • State “DONE” from “HOLD” [2024-10-24 Thu 22:08]
  • State “HOLD” from “WORKING” [2024-10-24 Thu 09:27]
  • State “WORKING” from “HOLD” [2024-10-24 Thu 09:20]
  • State “HOLD” from “WORKING” [2024-10-23 Wed 21:49]
  • State “WORKING” from “TODO” [2024-10-23 Wed 21:46]
[2024-10-23 Wed 16:06] In file: manifest.json
\"browser_action\": {
    \"browser_style\": true,
    \"default_icon\": \"img/icon.png\",
    // \"default_popup\": \"popup.html\",
    \"default_title\": \"Summary and Capture\"
},

like https://github.com/mdn/webextensions-examples/blob/main/beastify/popup/choose_beast.js load the background.js and capture the content

  1. The JavaScript file popup.js is required to communicate with the background.js file by sending messages directly. Failure to establish this direct communication may result in the disappearance of the popup page within the web application.
  2. When a popup page is specified in the manifest.json file, the click event on the icon is handled or intercepted by the popup.html file. This functionality allows for the display of a popup window when the icon associated with the extension is clicked, providing a user interface for additional interactions or information.

[#A] Setup the org and org-roam buttons :org-roam-capture-extension:

  • State “DONE” from “WORKING” [2024-10-25 Fri 10:12]
  • State “WORKING” from “TODO” [2024-10-25 Fri 09:59]
[2024-10-24 Thu 22:08] In file: styles.css

CANCELLED [#C] Setup streaming curl :org-roam-capture-extension:

[2024-10-24 Thu 22:26] In file: styles.css

https://community.openai.com/t/api-assistant-streaming-curl/731219

curl -N https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

Replace readability, as it modify the original page :org-roam-capture-extension:

  • State “DONE” from “WORKING” [2024-10-25 Fri 10:41]
  • State “WORKING” from “TODO” [2024-10-25 Fri 10:13]
[2024-10-25 Fri 10:13] In file: background.js
var readability_exec = browser.tabs.executeScript({ file: \"lib/Readability.js\" });

Better to remove it, it is not stable.

Fix the protocol format :org-roam-capture-extension:

  • State “DONE” from “HOLD” [2024-10-25 Fri 15:03]
  • State “HOLD” from “WORKING” [2024-10-25 Fri 13:46]
  • State “WORKING” from “TODO” [2024-10-25 Fri 12:57]
[2024-10-25 Fri 10:44] In file: background.js
// add org or org-roam protocol ///////////////////////////////////////////////
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
    if (request.action === \"saveOrg\") {
        chrome.storage.sync.get(null, (data) => {
            let uri;

            if (data.useNewStyleLinks) {
                uri = \"org-protocol://\" +
                data.protocol +
                    \"?template=\" +
                    data.template +
                    \"&url=\" +
                    request.url +
                    \"&title=\" +
                    request.title +
                    \"&body=\" +
                    request.content;
            } else {
                uri = \"org-protocol://\" +
                data.protocol +
                    \":/\" +
                    data.template +
                    \"/\" +
                    request.url +
                    \"/\" +
                    request.title +
                    \"/\" +
                    request.content;
            }

            console.log(uri); // Log the URI for debugging
            location.href = uri;
        });
    }
});

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
    if (request.action === \"saveRoam\") {
        let uri = \"org-protocol://\" +
        data.protocol +
            \"?template=\" +
            \"r\" +
            \"&ref=\" +
            request.url +
            \"&title=\" +
            request.title +
            \"&body=\" +
            request.content;
        console.log(uri); // Log the URI for debugging
        location.href = uri;
    }
});

Add Kimi model

  • State “DONE” from “CANCELLED” [2025-11-22 Sat 16:03]
  • State “CANCELLED” from “WORKING” [2025-11-22 Sat 16:03]
  • State “WORKING” from “TODO” [2025-07-29 Tue 13:42]
[2025-07-29 Tue 13:42] In file: projectile.org

put the console.log into debug control

  • State “DONE” from “TODO” [2025-12-08 Mon 11:58]
[2025-12-08 Mon 10:37] In file: background.js

CANCELLED change to base64 to encode the summary

[2025-12-08 Mon 10:38] In file: background.js

setup stream response

  • State “DONE” from “TODO” [2025-12-09 Tue 09:17]
[2025-12-09 Tue 08:26] In file: background.js

Note

Here popup intercepts click listener :org-roam-capture-extension:

[2024-10-23 Wed 16:04] In file: manifest.json

\"browser_action\": {
    \"browser_style\": true,
    \"default_icon\": \"img/icon.png\",
    // \"default_popup\": \"popup.html\",
    \"default_title\": \"Summary and Capture\"
},