Skip to content

str-bin/bark

 
 

Repository files navigation

AgentGPT Logo

This is a boilerplate and starter for Chrome browser extension, built with Wxt、 React、 Tailwind css 、Shadcn ui and Typescript. Support dark mode and localization

Node version English 简体中文

  •   🐦 X About me


🔐 Prerequisites ☝️

Before you get started, please make sure you have the following installed:

🗂️ Getting Started 🚀

  1. Open your editor

  2. Open the Terminal

    • Typically, you can do this from a 'Terminal' tab or by using a shortcut (e.g., Ctrl + ~ for Windows or Control + ~ for Mac in VS Code).
  3. Clone the Repository and Navigate into the Directory

    • Once your terminal is open, you can clone the repository and move into the directory by running the commands below.

    • For Mac/Linux users 🍎 🐧

    git clone git@github.com:imtiger/wxt-react-shadcn-tailwindcss-chrome-extension.git
    cd wxt-react-shadcn-tailwindcss-chrome-extension
    npm install
    npm run dev
    • For Windows users :windows:
    git clone git@github.com:imtiger/wxt-react-shadcn-tailwindcss-chrome-extension.git
    cd wxt-react-shadcn-tailwindcss-chrome-extension
    npm install
    npm run dev
  4. The browser will be auto opened

    • you will see the content-script panel and side panel

❇️ Tech Stack

🚀 Localization and i18n

The locales file in the locales folder ,and you can edit it.

initTranslations(i18nConfig.defaultLocale, ["common", "content"])

👀 Considerations

  • Chrome extension tailwind css rem not working shadow dom.

Because Tailwind CSS uses rem by default, and rem is computed based on the font-size of the html element on the page, even if a content-script uses shadow dom, the internal elements' rem are also calculated based on the root html element's font-size of the host page. Therefore, to prevent style differences in the plugin due to varying font-sizes set by different websites, we can modify the default configuration of Tailwind CSS, allowing it to calculate directly in pixels.

npm install @thedutchcoder/postcss-rem-to-px
//postcss.config.js
export default {
   plugins: {
      tailwindcss: {},
      '@thedutchcoder/postcss-rem-to-px': {}, // you can add option like the base font size
      autoprefixer: {},
   },    
};
  • Add new component
npx shadcn-ui@latest add
  • Not trigger the click event listener.

    When a popup or side panel is defined, and set

browser.sidePanel.setPanelBehavior({openPanelOnActionClick: true}).catch((error: any) => console.error(error));

clicking on the browser extension icon won't trigger the listening event,and just open the side panel.

//monitor the event from extension icon click
browser.action.onClicked.addListener((tab) => {
   // 发送消息给content-script.js
   console.log("click icon")
   console.log(tab)
   browser.tabs.sendMessage(tab.id!, {messageType: MessageType.clickExtIcon});
});

👨‍🚀About Me

  • Full-Stack Engineer

  • Once worked at Tencent and Alibaba

Github
Twitter/X

If this project is helpful to you, star the repo and buy be a coffee, thank you guys.

Buy Me A Coffee

赞赏作者

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 84.1%
  • CSS 7.5%
  • JavaScript 6.8%
  • HTML 1.6%