mirror of
https://github.com/NohamR/KartablePro.git
synced 2025-05-24 00:48:58 +00:00
publish
This commit is contained in:
parent
8a62d38f93
commit
15f6b3b2df
26
README.md
Normal file
26
README.md
Normal 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.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
3. Rendez-vous sur [kartable.fr](https://www.kartable.fr/terminale/) et naviguer vers le sujet ou la fiche qui vous intéresse.
|
||||
|
||||

|
||||

|
||||
|
||||
## 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.
|
155
load.js
155
load.js
@ -1,81 +1,51 @@
|
||||
// function fetchContent(url) {
|
||||
// fetch(url)
|
||||
// .then(response => {
|
||||
// if (response.ok) {
|
||||
// return response.text();
|
||||
// }
|
||||
// throw new Error(`Failed to fetch: ${response.statusText}`);
|
||||
// })
|
||||
// .then(html => {
|
||||
// const parser = new DOMParser();
|
||||
// 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 => {
|
||||
if (response.ok) {
|
||||
return response.text();
|
||||
}
|
||||
throw new Error(`Failed to fetch: ${response.statusText}`);
|
||||
})
|
||||
.then(html => {
|
||||
const newWindow = window.open();
|
||||
newWindow.location.href = "about:blank";
|
||||
newWindow.document.write(html);
|
||||
newWindow.document.close();
|
||||
})
|
||||
.catch(error => console.error(error));
|
||||
} else {
|
||||
console.log('Aucun nombre trouvé à la fin de l\'URL.');
|
||||
function fetchAndModifyContent(url, V) {
|
||||
let link;
|
||||
if (V === 'V1'){
|
||||
link = url;
|
||||
}
|
||||
else {
|
||||
link = 'https://www.kartable.fr' + url;
|
||||
}
|
||||
console.log(link, V);
|
||||
fetch(link)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.text();
|
||||
}
|
||||
throw new Error(`Failed to fetch: ${response.statusText}`);
|
||||
})
|
||||
.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();
|
||||
newWindow.location.href = "about:blank";
|
||||
newWindow.document.write(html);
|
||||
newWindow.document.close();
|
||||
|
||||
}
|
||||
|
||||
function replaceArticles() {
|
||||
@ -91,10 +61,7 @@ function replaceArticles() {
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
var link = titleElement.getAttribute('href');
|
||||
|
||||
if (link) {
|
||||
opener(link);
|
||||
}
|
||||
fetchAndModifyContent(link, 'V2');
|
||||
});
|
||||
|
||||
article.parentNode.replaceChild(button, article);
|
||||
@ -112,13 +79,31 @@ function replaceArticles() {
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
var link = article.querySelector('h3 a');
|
||||
|
||||
if (link) {
|
||||
opener(link.href);
|
||||
}
|
||||
var url = link.href;
|
||||
fetchAndModifyContent(url, 'V1');
|
||||
});
|
||||
|
||||
article.parentNode.replaceChild(button, article);
|
||||
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();
|
BIN
readme/charger-extension.png
Normal file
BIN
readme/charger-extension.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
BIN
readme/ex1.png
Normal file
BIN
readme/ex1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
BIN
readme/ex2.png
Normal file
BIN
readme/ex2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
BIN
readme/extension.png
Normal file
BIN
readme/extension.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
readme/mode-dev.png
Normal file
BIN
readme/mode-dev.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
Loading…
x
Reference in New Issue
Block a user