Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrigindo erros com a mudança do gulp #64

Merged
merged 12 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"build": "NODE_ENV=prod run-s clear build:web build:prepare build:prod",
"build:prepare": "node tasks/prepare.prod.mjs build",
"build:web": "vite build",
"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'",
"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'",
"build:dev": "tsup --onSuccess 'node --no-warnings=ExperimentalWarning tasks/mvsw.dev.mjs'",
"build:prod": "tsup --onSuccess 'node --no-warnings=ExperimentalWarning tasks/mvsw.prod.mjs'",
"clear": "rimraf extension/prod"
},
"standard": {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<script src="../lib/xdLocalStoragePostMessageApi.min.js"></script>
</head>
<body>
UFABC Next Storage
Next Storage
</body>
</html>
50 changes: 20 additions & 30 deletions src/scripts/contentScriptPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import Utils from "../utils/extensionUtils";
import { NextAPI } from "../services/NextAPI";
import Axios from "axios";
import Toastify from "toastify-js";
import "toastify-js/src/toastify.css";
const loading = require("../assets/loading.svg");
const errorSVG = require("../assets/error.svg");
const logoWhite = require("../assets/logo-white.svg");

const getURL = chrome.runtime.getURL ?? ((path) => path);

const nextApi = NextAPI();

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

if (isIndexPortalAluno()) {
const basePortalAlunoURL = new URL(document.location.href);
const isPortalAluno = basePortalAlunoURL.pathname === "/dados_pessoais";
const isFichasIndividuais =
basePortalAlunoURL.pathname === "/fichas_individuais";
const isStudentFicha = basePortalAlunoURL.pathname === "/ficha_individual";

if (isPortalAluno) {
const anchor = document.createElement("div");
anchor.setAttribute("id", "app");
document.body.append(anchor);
Utils.injectScript("studentPortal.js");

Utils.injectStyle("styles/portal.css");

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

toast.showToast();

iterateTabelaCursosAndSaveToLocalStorage();
} else if (isFichaIndividualPath()) {
} else if (isStudentFicha) {
Utils.injectStyle("styles/portal.css");
}

function isIndexPortalAluno() {
return (
document.location.href.indexOf("aluno.ufabc.edu.br/dados_pessoais") !== -1
);
}

function isFichasIndividuaisPath() {
return (
document.location.href.indexOf("aluno.ufabc.edu.br/fichas_individuais") !==
-1
);
}

function isFichaIndividualPath() {
return (
document.location.href.indexOf("aluno.ufabc.edu.br/ficha_individual") !== -1
);
}

function iterateTabelaCursosAndSaveToLocalStorage() {
var tabelaCursos = $("tbody").children().slice(1);
let count = 0;
Expand Down Expand Up @@ -182,14 +169,17 @@ async function getFichaAluno(fichaAlunoUrl, nomeDoCurso, anoDaGrade) {
Toastify({
text: `
<div style="width: 228px; display: flex; align-items: end; margin-right: 12px;">
<img style="margin-right: 16px;" width="32" height="32" src="${errorSVG}" />
<img style="margin-right: 16px;" width="32" height="32" src="${getURL(
"/assets/error.svg"
)}" />
Não foi possível salvar seus dados, recarregue a página e aguarde.
</div>`,
duration: -1,
close: true,
gravity: "top",
position: "right",
className: "toast-error-container",
escapeMarkup: false,
style: {
background: "#E74C3C;",
},
Expand Down
2 changes: 1 addition & 1 deletion src/services/NextAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function resolveEndpoint(env) {
{
development: "http://localhost:8011/v1",
staging: "https://ufabc-matricula-test.cdd.naoseiprogramar.com.br/v1",
production: "https://api.ufabcnext.com/v1",
prod: "https://api.ufabcnext.com/v1",
}[env] || "http://localhost:8011/v1"
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/styles/main.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Keep in mind that when you inject main.css you inject all this files to the website */
@import "../../node_modules/toastr/build/toastr.min.css";
/*@import "../../node_modules/element-ui/lib/theme-chalk/index.css";*/
@import "./toastr.css";
@import "../../node_modules/element-ui/lib/theme-chalk/index.css";
@import "../../node_modules/vuetify/dist/vuetify.min.css";

@import url("https://fonts.googleapis.com/css?family=Ubuntu");
Expand Down
11 changes: 5 additions & 6 deletions src/styles/portal.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@import "../../node_modules/toastr/build/toastr.min.css";

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

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

.toast-loading {
display: flex;
Expand Down Expand Up @@ -58,7 +57,7 @@
font-stretch: normal;
line-height: 1.38;
letter-spacing: normal;
color: rgba(0, 0, 0, 0.75);
color: rgba(0, 0, 0, 0.75);
}

#conteudo #page > p:nth-child(3) {
Expand Down
87 changes: 87 additions & 0 deletions src/styles/toastify.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*!
* Toastify js 1.12.0
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/

.toastify {
padding: 12px 20px;
color: #ffffff;
display: inline-block;
box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12),
0 10px 36px -4px rgba(77, 96, 232, 0.3);
background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
background: linear-gradient(135deg, #73a5ff, #5477f5);
position: fixed;
opacity: 0;
transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
border-radius: 2px;
cursor: pointer;
text-decoration: none;
max-width: calc(50% - 20px);
z-index: 2147483647;
}

.toastify.on {
opacity: 1;
}

.toast-close {
background: transparent;
border: 0;
color: white;
cursor: pointer;
font-family: inherit;
font-size: 1em;
opacity: 0.4;
padding: 0 5px;
}

.toastify-right {
right: 15px;
}

.toastify-left {
left: 15px;
}

.toastify-top {
top: -150px;
}

.toastify-bottom {
bottom: -150px;
}

.toastify-rounded {
border-radius: 25px;
}

.toastify-avatar {
width: 1.5em;
height: 1.5em;
margin: -7px 5px;
border-radius: 2px;
}

.toastify-center {
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
max-width: fit-content;
max-width: -moz-fit-content;
}

@media only screen and (max-width: 360px) {
.toastify-right,
.toastify-left {
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
max-width: fit-content;
}
}
Loading