mirror of
https://github.com/NohamR/KartablePro.git
synced 2025-05-24 00:48:58 +00:00
not working
This commit is contained in:
parent
e2faf9a5fe
commit
8a62d38f93
131
.gitignore
vendored
Normal file
131
.gitignore
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
# Editors
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# Vagrant
|
||||
.vagrant/
|
||||
|
||||
# Mac/OSX
|
||||
.DS_Store
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
|
||||
# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
dist_chrome/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# node
|
||||
node_modules/
|
||||
|
||||
test/
|
0
background.js
Normal file
0
background.js
Normal file
BIN
images/icon.png
Normal file
BIN
images/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
BIN
images/icon128.png
Normal file
BIN
images/icon128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
BIN
images/icon16.png
Normal file
BIN
images/icon16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
images/icon48.png
Normal file
BIN
images/icon48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
124
load.js
Normal file
124
load.js
Normal file
@ -0,0 +1,124 @@
|
||||
// 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 replaceArticles() {
|
||||
var articles = document.querySelectorAll('.document-list__item');
|
||||
|
||||
articles.forEach(function (article) {
|
||||
var titleElement = article.querySelector('.document-list__title');
|
||||
|
||||
if (titleElement) {
|
||||
var articleText = titleElement.textContent;
|
||||
var button = document.createElement('button');
|
||||
button.textContent = articleText;
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
var link = titleElement.getAttribute('href');
|
||||
|
||||
if (link) {
|
||||
opener(link);
|
||||
}
|
||||
});
|
||||
|
||||
article.parentNode.replaceChild(button, article);
|
||||
console.log('done');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var articles = document.querySelectorAll('.document-readable');
|
||||
|
||||
articles.forEach(function (article) {
|
||||
var articleText = article.querySelector('h3').textContent;
|
||||
var button = document.createElement('button');
|
||||
button.textContent = articleText;
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
var link = article.querySelector('h3 a');
|
||||
|
||||
if (link) {
|
||||
opener(link.href);
|
||||
}
|
||||
});
|
||||
|
||||
article.parentNode.replaceChild(button, article);
|
||||
console.log('done');
|
||||
});
|
||||
}
|
28
manifest.json
Normal file
28
manifest.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "KartablePro",
|
||||
"version": "1.0",
|
||||
"description": "Débloque tous les articles sur Kartable gratuitement",
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"storage",
|
||||
"tabs"
|
||||
],
|
||||
"action": {
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"16": "images/icon16.png",
|
||||
"48": "images/icon48.png",
|
||||
"128": "images/icon128.png"
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
"service_worker": "background.js"
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://www.kartable.fr/*"],
|
||||
"js": ["load.js"]
|
||||
}
|
||||
]
|
||||
}
|
18
popup.html
Normal file
18
popup.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AnnabacPro</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>AnnabacPro</h1>
|
||||
Fait par <a href="#" id="redirectButton1">√(noham)²</a>
|
||||
<br>
|
||||
repo : <a href="#" id="redirectButton2">KartablePro</a>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
13
popup.js
Normal file
13
popup.js
Normal file
@ -0,0 +1,13 @@
|
||||
// popup.js
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var redirectButton1 = document.getElementById('redirectButton1');
|
||||
redirectButton1.addEventListener('click', function () {
|
||||
window.open('https://nohamr.github.io', '_blank');
|
||||
});
|
||||
var redirectButton2 = document.getElementById('redirectButton2');
|
||||
redirectButton2.addEventListener('click', function () {
|
||||
window.open('https://github.com/NohamR/KartablePro', '_blank');
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user