Skip to content

Commit

Permalink
Merge pull request #165 from NIAEFEUP/refactor/webpack
Browse files Browse the repository at this point in the history
Use webpack for the build step
  • Loading branch information
thePeras authored Jul 19, 2024
2 parents e202783 + 3db7f94 commit ba34c42
Show file tree
Hide file tree
Showing 17 changed files with 13,310 additions and 4,932 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ bundle/safari
.vscode

# Xcode project
xcuserdata/
xcuserdata/

# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
# !.yarn/sdks
!.yarn/versions
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
## Development / Building / Bundling the Extension
## Development

First, you must have [yarn](https://classic.yarnpkg.com/lang/en/docs/install) installed.

Run
Install dependencies:

```sh
yarn && yarn bundle [all | firefox | chrome | safari]
yarn install
```
at the root directory and you'll get a bundle directory that looks like this:

To develop choose your favorite browser.
```sh
yarn run dev:firefox
```
📂 bundle
└ 📁 chrome
└ 📁 firefox
└ 📁 safari
└ 🗄️ chrome.zip
└ 🗄️ firefox.zip
└ 🗄️ safari.zip
or
```sh
yarn run dev:chrome
```

## Watch for changes
This command will initialize a browser window and load the extension, watching for changes.

```sh
sudo yarn watch [firefox | chrome | safari]
```
You read to start!

The extension polls the watch webserver for changes, if the page doesn't reload automatically, reload the extension and if that doesn't work, see the service worker/background script console for errors.
## Building a bundle

## Load Extension
```sh
yarn build
```

You can bundle the extension for `Chrome`, `Firefox`, and `Safari`:
## Load a bundle

<table>
<tr>
Expand Down Expand Up @@ -60,6 +59,4 @@ You can bundle the extension for `Chrome`, `Firefox`, and `Safari`:
</ol>
</td>
</tr>
</table>

#### This respository was based on the [typefully/minimal-twitter](https://github.com/typefully/minimal-twitter) extension repository
</table>
15 changes: 10 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ const popupOptions = {
font: "on",
};

const reloadFEUPSigarraPages = () => {
chrome.tabs.query({ url: "*://sigarra.up.pt/feup/*" }, (tabs) => {
tabs.forEach((tab) => {
chrome.tabs.reload(tab.id);
});
});
}

chrome.runtime.onInstalled.addListener((object) => {
if (object.reason === "install") {
chrome.tabs.query({ url: "*://sigarra.up.pt/feup/*" }, (tabs) => {
tabs.forEach((tab) => {
chrome.tabs.reload(tab.id);
});
});
reloadFEUPSigarraPages()

if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
chrome.tabs.create({
Expand All @@ -30,6 +34,7 @@ chrome.runtime.onInstalled.addListener((object) => {
}

if (object.reason === "update") {
reloadFEUPSigarraPages();
for (const opt in popupOptions) {
if (chrome.storage.local.get(opt) == null)
chrome.storage.local.set({[opt]: popupOptions[opt]});
Expand Down
256 changes: 0 additions & 256 deletions bundle-script.js

This file was deleted.

2 changes: 1 addition & 1 deletion content-scripts/src/pages/teacher_page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {groupSectionTitleAndContent, groupChildrenBySelector, moveChildrenToAncestor, moveChildrenToAncestor, removeTwoColumnTable} from "../modules/utilities/pageUtils"
import {groupSectionTitleAndContent, groupChildrenBySelector, moveChildrenToAncestor, removeTwoColumnTable} from "../modules/utilities/pageUtils"


const publicationWebsites = {
Expand Down
24 changes: 0 additions & 24 deletions dev/background.js

This file was deleted.

Loading

0 comments on commit ba34c42

Please sign in to comment.