This commit is contained in:
√(noham)² committed 2024-02-03 23:50:09 +01:00
1 parent 8a62d38f93
commit 15f6b3b2df
8 files changed
+5855 -75

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
# Extension Chrome KartablePro
KartablePro est une extension Chrome qui débloque gratuitement tous les articles sur Annabac. Dites adieu aux barrières de paiement et accédez aux contenus Annabac sans aucune restriction.
## Installation
1. Téléchargez l'archive .zip de l'extension [ici](https://github.com/NohamR/KartablePro/releases/latest) et déziper la.
2. Allez sur [chrome://extensions/](chrome://extensions/).
Activez le mode "Développeur" dans le coin supérieur droit.
Cliquez sur "Charger l'extension non empaquetée" et sélectionnez le dossier de l'extension.
![activer le mode dev](readme/mode-dev.png)
![charger l'extension non empaquetée](readme/charger-extension.png)
![extension](readme/extension.png)
3. Rendez-vous sur [kartable.fr](https://www.kartable.fr/terminale/) et naviguer vers le sujet ou la fiche qui vous intéresse.
![ex](readme/ex1.png)
![ex](readme/ex2.png)
## Utilisation
Il est possible d'utiliser l'extension avec ou sans compte. L'usage d'un compte apporte plus de facilité pour la navigation entre les matières.
## Avertissement
Cette extension est destinée à des fins éducatives et informatives uniquement. Le développeur n'est pas responsable de tout usage abusif ou d'un accès non autorisé au contenu.
+5769
View File
File diff suppressed because it is too large. Load diff
+60 -75
View File
@@ -1,65 +1,13 @@
// function fetchContent(url) { function fetchAndModifyContent(url, V) {
// fetch(url) let link;
// .then(response => { if (V === 'V1'){
// if (response.ok) { link = url;
// return response.text(); }
// } else {
// throw new Error(`Failed to fetch: ${response.statusText}`); link = 'https://www.kartable.fr' + url;
// }) }
// .then(html => { console.log(link, V);
// const parser = new DOMParser(); fetch(link)
// const doc = parser.parseFromString(html, 'text/html');
// // Get the content of the script tag with id "kartable-state"
// const scriptElement = doc.getElementById('kartable-state');
// if (scriptElement) {
// const scriptContent = JSON.parse(scriptElement.textContent);
// // List every key in scriptContent
// const keys = Object.keys(scriptContent);
// // Check if there is a key at index 8
// if (keys.length > 8) {
// const keyAtIndex8 = keys[8];
// const contentAtIndex8 = scriptContent[keyAtIndex8];
// console.log(contentAtIndex8);
// return contentAtIndex8
// } else {
// console.error('Key at index 8 not found in scriptContent');
// }
// } else {
// console.error('Script with id "kartable-state" not found');
// }
// })
// .catch(error => console.error(error));
// }
// fetchContent(window.location.href);
// window.onload = function() {
// replaceArticles();
// console.log('done')
// };
window.onload = function() {
setTimeout(function() {
replaceArticles();
}, 3000);
};
function opener(url) {
console.log(url);
const match = url.match(/(\d+)$/);
if (match) {
const number = match[0];
console.log('Nombre à la fin de l\'URL :', number);
fetch(`https://www.kartable.fr/ressources/a/a/a/${number}`)
.then(response => { .then(response => {
if (response.ok) { if (response.ok) {
return response.text(); return response.text();
@@ -67,15 +15,37 @@ function opener(url) {
throw new Error(`Failed to fetch: ${response.statusText}`); throw new Error(`Failed to fetch: ${response.statusText}`);
}) })
.then(html => { .then(html => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const innerContent = doc.querySelector('.document--wrapper');
// const innerContentMain = innerContent.querySelector('document--wrapper');
if (innerContent) {
let innerContentText = Array.from(innerContent.childNodes)
.map(node => node.outerHTML || node.nodeValue)
.join('');
assignContent(innerContentText);
} else {
console.log('Inner content not found');
}
})
.catch(error => console.error(error));
}
function assignContent(content) {
const html = `
<!doctypehtml><html dir=ltr lang=fr-FR><base href=/ ><meta charset=UTF-8><meta name=description><meta name=viewport content="width=device-width,initial-scale=1"><meta name=apple-itunes-app content="app-id=825500330"><link href=https://assets.kartable.fr/front/assets/css/main.min.1705586312.css rel=stylesheet><meta name=msapplication-TileColor content=#ffffff><meta name=msapplication-TileImage content=/web/ms-icon-144x144.png><meta name=theme-color content=#ffffff><link href=https://fonts.gstatic.com/ rel=preconnect crossorigin=""><link href=https://www.googletagmanager.com/ rel=preconnect><link href=https://www.google-analytics.com/ rel=preconnect><link href=https://connect.facebook.net/ rel=preconnect><link href=https://cdn.scarabresearch.com/ rel=preconnect><link href=https://static.scarabresearch.com/ rel=preconnect><link href=https://nohamr.github.io/big.css rel=stylesheet><body><kartable-app ng-server-context=ssr ng-version=16.1.6><router-outlet webpsupport=""></router-outlet><ng-component _nghost-kartable-c1819110449=""class=ng-star-inserted data-is-themable=""><div _ngcontent-kartable-c1819110449=""class=navigation-wrapper><div _ngcontent-kartable-c1819110449=""class=navigation__main><main _ngcontent-kartable-c1819110449=""class="gu-unselectable page page--document--no-user page--document-single page--documents"><div _ngcontent-kartable-c1819110449=""class=document--wrapper>${content}</div></main></div></div></kartable-app><script>!function(){var e=window.navigator.userAgent,r=e.indexOf("MSIE "),a=e.indexOf("IEMobile");(0<r||0<a)&&alert("Vous utilisez un navigateur qui n'est pas compatible avec la dernière version de Kartable. Nous vous recommandons de télécharger un autre navigateur (Chrome, Firefox) ou de mettre à jour la version de votre navigateur courant.")}()</script>
`;
console.log('page opened');
const newWindow = window.open(); const newWindow = window.open();
newWindow.location.href = "about:blank"; newWindow.location.href = "about:blank";
newWindow.document.write(html); newWindow.document.write(html);
newWindow.document.close(); newWindow.document.close();
})
.catch(error => console.error(error));
} else {
console.log('Aucun nombre trouvé à la fin de l\'URL.');
}
} }
function replaceArticles() { function replaceArticles() {
@@ -91,10 +61,7 @@ function replaceArticles() {
button.addEventListener('click', function () { button.addEventListener('click', function () {
var link = titleElement.getAttribute('href'); var link = titleElement.getAttribute('href');
fetchAndModifyContent(link, 'V2');
if (link) {
opener(link);
}
}); });
article.parentNode.replaceChild(button, article); article.parentNode.replaceChild(button, article);
@@ -112,13 +79,31 @@ function replaceArticles() {
button.addEventListener('click', function () { button.addEventListener('click', function () {
var link = article.querySelector('h3 a'); var link = article.querySelector('h3 a');
var url = link.href;
if (link) { fetchAndModifyContent(url, 'V1');
opener(link.href);
}
}); });
article.parentNode.replaceChild(button, article); article.parentNode.replaceChild(button, article);
console.log('done'); console.log('done');
}); });
var articles = document.querySelectorAll('.category');
articles.forEach(function (article) {
var categoryTitle = article.querySelector('.category__title').textContent.trim();
var button = document.createElement('button');
button.textContent = categoryTitle;
button.addEventListener('click', function () {
var link = article.querySelector('.category__link');
var url = link.getAttribute('href');
fetchAndModifyContent(url, 'V1');
});
article.parentNode.replaceChild(button, article);
console.log('done done')
});
} }
replaceArticles();
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB