Skip to content

Commit 7605a65

Browse files
authored
Merge pull request #64 from ufabc-next/chore/refactor-lib
Corrigindo erros com a mudança do gulp
2 parents b9af91d + 289ee84 commit 7605a65

File tree

13 files changed

+451
-49
lines changed

13 files changed

+451
-49
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"build": "NODE_ENV=prod run-s clear build:web build:prepare build:prod",
1212
"build:prepare": "node tasks/prepare.prod.mjs build",
1313
"build:web": "vite build",
14-
"build:dev": "tsup src/scripts/background.js src/scripts/contentscript.js --target=node20 --format iife --out-dir extension/dev/dist --no-splitting --onSuccess 'node --no-warnings=ExperimentalWarning tasks/mvsw.dev.mjs'",
15-
"build:prod": "tsup src/scripts/background.js src/scripts/contentscript.js --target=node20 --minify --format iife --out-dir extension/prod/dist --no-splitting --onSuccess 'node --no-warnings=ExperimentalWarning tasks/mvsw.prod.mjs'",
14+
"build:dev": "tsup --onSuccess 'node --no-warnings=ExperimentalWarning tasks/mvsw.dev.mjs'",
15+
"build:prod": "tsup --onSuccess 'node --no-warnings=ExperimentalWarning tasks/mvsw.prod.mjs'",
1616
"clear": "rimraf extension/prod"
1717
},
1818
"standard": {

src/pages/iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<script src="../lib/xdLocalStoragePostMessageApi.min.js"></script>
55
</head>
66
<body>
7-
UFABC Next Storage
7+
Next Storage
88
</body>
99
</html>

src/scripts/contentScriptPortal.js

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import Utils from "../utils/extensionUtils";
55
import { NextAPI } from "../services/NextAPI";
66
import Axios from "axios";
77
import Toastify from "toastify-js";
8-
import "toastify-js/src/toastify.css";
9-
const loading = require("../assets/loading.svg");
10-
const errorSVG = require("../assets/error.svg");
11-
const logoWhite = require("../assets/logo-white.svg");
8+
9+
const getURL = chrome.runtime.getURL ?? ((path) => path);
1210

1311
const nextApi = NextAPI();
1412

1513
const toast = new Toastify({
1614
text: `
1715
<div class='toast-loading-text' style='width: 250px'>
18-
<img src=${logoWhite} width="120" style="margin-bottom: 8px" />
16+
<img src=${getURL(
17+
"/assets/logo-white.svg"
18+
)} width="120" style="margin-bottom: 8px" />
1919
<p style="padding-bottom: 8px;">Atualizando suas informações...</p>\n\n
2020
<b>NÃO SAIA DESSA PÁGINA,</b>
2121
<p>apenas aguarde, no máx. 5 min 🙏</p>
@@ -26,51 +26,38 @@ const toast = new Toastify({
2626
position: "right",
2727
className: "toast-loading",
2828
escapeMarkup: false,
29-
avatar: loading,
29+
avatar: getURL("/assets/loading.svg"),
3030
style: {
3131
background: "linear-gradient(to right, #2E7EED, rgba(46, 126, 237, 0.5));",
3232
},
3333
});
3434

35-
if (isIndexPortalAluno()) {
35+
const basePortalAlunoURL = new URL(document.location.href);
36+
const isPortalAluno = basePortalAlunoURL.pathname === "/dados_pessoais";
37+
const isFichasIndividuais =
38+
basePortalAlunoURL.pathname === "/fichas_individuais";
39+
const isStudentFicha = basePortalAlunoURL.pathname === "/ficha_individual";
40+
41+
if (isPortalAluno) {
3642
const anchor = document.createElement("div");
3743
anchor.setAttribute("id", "app");
3844
document.body.append(anchor);
39-
Utils.injectScript("studentPortal.js");
4045

4146
Utils.injectStyle("styles/portal.css");
47+
4248
toastr.info(
4349
"Clique em <a href='https://aluno.ufabc.edu.br/fichas_individuais' style='color: #FFF !important;'>Ficha Individual</a> para atualizar suas informações!"
4450
);
45-
} else if (isFichasIndividuaisPath()) {
51+
} else if (isFichasIndividuais) {
4652
Utils.injectStyle("styles/portal.css");
4753

4854
toast.showToast();
4955

5056
iterateTabelaCursosAndSaveToLocalStorage();
51-
} else if (isFichaIndividualPath()) {
57+
} else if (isStudentFicha) {
5258
Utils.injectStyle("styles/portal.css");
5359
}
5460

55-
function isIndexPortalAluno() {
56-
return (
57-
document.location.href.indexOf("aluno.ufabc.edu.br/dados_pessoais") !== -1
58-
);
59-
}
60-
61-
function isFichasIndividuaisPath() {
62-
return (
63-
document.location.href.indexOf("aluno.ufabc.edu.br/fichas_individuais") !==
64-
-1
65-
);
66-
}
67-
68-
function isFichaIndividualPath() {
69-
return (
70-
document.location.href.indexOf("aluno.ufabc.edu.br/ficha_individual") !== -1
71-
);
72-
}
73-
7461
function iterateTabelaCursosAndSaveToLocalStorage() {
7562
var tabelaCursos = $("tbody").children().slice(1);
7663
let count = 0;
@@ -182,14 +169,17 @@ async function getFichaAluno(fichaAlunoUrl, nomeDoCurso, anoDaGrade) {
182169
Toastify({
183170
text: `
184171
<div style="width: 228px; display: flex; align-items: end; margin-right: 12px;">
185-
<img style="margin-right: 16px;" width="32" height="32" src="${errorSVG}" />
172+
<img style="margin-right: 16px;" width="32" height="32" src="${getURL(
173+
"/assets/error.svg"
174+
)}" />
186175
Não foi possível salvar seus dados, recarregue a página e aguarde.
187176
</div>`,
188177
duration: -1,
189178
close: true,
190179
gravity: "top",
191180
position: "right",
192181
className: "toast-error-container",
182+
escapeMarkup: false,
193183
style: {
194184
background: "#E74C3C;",
195185
},

src/services/NextAPI.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function resolveEndpoint(env) {
55
{
66
development: "http://localhost:8011/v1",
77
staging: "https://ufabc-matricula-test.cdd.naoseiprogramar.com.br/v1",
8-
production: "https://api.ufabcnext.com/v1",
8+
prod: "https://api.ufabcnext.com/v1",
99
}[env] || "http://localhost:8011/v1"
1010
);
1111
}

src/styles/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Keep in mind that when you inject main.css you inject all this files to the website */
2-
@import "../../node_modules/toastr/build/toastr.min.css";
3-
/*@import "../../node_modules/element-ui/lib/theme-chalk/index.css";*/
2+
@import "./toastr.css";
3+
@import "../../node_modules/element-ui/lib/theme-chalk/index.css";
44
@import "../../node_modules/vuetify/dist/vuetify.min.css";
55

66
@import url("https://fonts.googleapis.com/css?family=Ubuntu");

src/styles/portal.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
@import "../../node_modules/toastr/build/toastr.min.css";
2-
3-
@import url('https://fonts.googleapis.com/css?family=Ubuntu');
4-
@import url('https://fonts.googleapis.com/css?family=Lato');
5-
1+
@import url("https://fonts.googleapis.com/css?family=Ubuntu");
2+
@import url("https://fonts.googleapis.com/css?family=Lato");
3+
@import url("./toastr.css");
4+
@import url("./toastify.css");
65

76
.toast-loading {
87
display: flex;
@@ -58,7 +57,7 @@
5857
font-stretch: normal;
5958
line-height: 1.38;
6059
letter-spacing: normal;
61-
color: rgba(0, 0, 0, 0.75);
60+
color: rgba(0, 0, 0, 0.75);
6261
}
6362
6463
#conteudo #page > p:nth-child(3) {

src/styles/toastify.css

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*!
2+
* Toastify js 1.12.0
3+
* https://github.com/apvarun/toastify-js
4+
* @license MIT licensed
5+
*
6+
* Copyright (C) 2018 Varun A P
7+
*/
8+
9+
.toastify {
10+
padding: 12px 20px;
11+
color: #ffffff;
12+
display: inline-block;
13+
box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12),
14+
0 10px 36px -4px rgba(77, 96, 232, 0.3);
15+
background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
16+
background: linear-gradient(135deg, #73a5ff, #5477f5);
17+
position: fixed;
18+
opacity: 0;
19+
transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
20+
border-radius: 2px;
21+
cursor: pointer;
22+
text-decoration: none;
23+
max-width: calc(50% - 20px);
24+
z-index: 2147483647;
25+
}
26+
27+
.toastify.on {
28+
opacity: 1;
29+
}
30+
31+
.toast-close {
32+
background: transparent;
33+
border: 0;
34+
color: white;
35+
cursor: pointer;
36+
font-family: inherit;
37+
font-size: 1em;
38+
opacity: 0.4;
39+
padding: 0 5px;
40+
}
41+
42+
.toastify-right {
43+
right: 15px;
44+
}
45+
46+
.toastify-left {
47+
left: 15px;
48+
}
49+
50+
.toastify-top {
51+
top: -150px;
52+
}
53+
54+
.toastify-bottom {
55+
bottom: -150px;
56+
}
57+
58+
.toastify-rounded {
59+
border-radius: 25px;
60+
}
61+
62+
.toastify-avatar {
63+
width: 1.5em;
64+
height: 1.5em;
65+
margin: -7px 5px;
66+
border-radius: 2px;
67+
}
68+
69+
.toastify-center {
70+
margin-left: auto;
71+
margin-right: auto;
72+
left: 0;
73+
right: 0;
74+
max-width: fit-content;
75+
max-width: -moz-fit-content;
76+
}
77+
78+
@media only screen and (max-width: 360px) {
79+
.toastify-right,
80+
.toastify-left {
81+
margin-left: auto;
82+
margin-right: auto;
83+
left: 0;
84+
right: 0;
85+
max-width: fit-content;
86+
}
87+
}

0 commit comments

Comments
 (0)