From b12416b67348181801886a5e6d9958f2f8abc776 Mon Sep 17 00:00:00 2001 From: jeremie <91679287+JeremieGiffard@users.noreply.github.com> Date: Mon, 27 Jan 2025 20:33:37 +0100 Subject: [PATCH] =?UTF-8?q?BNF=20only=20:=20acc=C3=A8s=20=C3=A0=20pressrea?= =?UTF-8?q?der=20(#287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ophirofox/content_scripts/pressreader.css | 16 ++++++++++++++ ophirofox/content_scripts/pressreader.js | 26 +++++++++++++++++++++++ ophirofox/manifest.json | 15 ++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ophirofox/content_scripts/pressreader.css create mode 100644 ophirofox/content_scripts/pressreader.js diff --git a/ophirofox/content_scripts/pressreader.css b/ophirofox/content_scripts/pressreader.css new file mode 100644 index 0000000..8c8c0c0 --- /dev/null +++ b/ophirofox/content_scripts/pressreader.css @@ -0,0 +1,16 @@ +.ophirofox-europresse { + visibility: visible !important; + position: fixed; + text-align: center; + width: 100%; + top: 0px; + left: 0px; + z-index: 50; +} +.ophirofox-europresse > a { + color: #fff !important; + padding: 1px 20px; + font-weight: 600; + background-color: #2bc48c; + border-radius: 25px; +} diff --git a/ophirofox/content_scripts/pressreader.js b/ophirofox/content_scripts/pressreader.js new file mode 100644 index 0000000..788ecbb --- /dev/null +++ b/ophirofox/content_scripts/pressreader.js @@ -0,0 +1,26 @@ +async function createLink(AUTH_URL) { + const div = document.createElement("div"); + div.className = "ophirofox-europresse" + const a = document.createElement("a"); + a.textContent = "Cliquez pour lire avec BNF" + var newUrl = new URL(window.location);//current page + newUrl.host = AUTH_URL //change only the domain name + a.href = newUrl; + + div.appendChild(a); + return div; +} + +/** + * @description website navigation without window reload. + */ +async function onLoad() { + const config = await configurationsSpecifiques(['BNF']) + if(!config) return; + //too much js dom updates everywere to choose a more specific DOM.element. + const element = document.querySelector('body'); + if (!element) return; + element.insertAdjacentElement('beforeend', await createLink(config.AUTH_URL_PRESSREADER)); +} + +onLoad().catch(console.error) \ No newline at end of file diff --git a/ophirofox/manifest.json b/ophirofox/manifest.json index 882e36d..4619b6b 100644 --- a/ophirofox/manifest.json +++ b/ophirofox/manifest.json @@ -662,6 +662,18 @@ "css": [ "content_scripts/arret-sur-images.css" ] + }, + { + "matches": [ + "https://www.pressreader.com/*" + ], + "js": [ + "content_scripts/config.js", + "content_scripts/pressreader.js" + ], + "css": [ + "content_scripts/pressreader.css" + ] } ], "browser_specific_settings": { @@ -698,7 +710,8 @@ { "name": "BNF", "AUTH_URL": "https://bnf.idm.oclc.org/login?url=https://nouveau.europresse.com/access/ip/default.aspx?un=D000067U_1", - "AUTH_URL_ARRETSURIMAGES" : "www-arretsurimages-net.bnf.idm.oclc.org" + "AUTH_URL_ARRETSURIMAGES" : "www-arretsurimages-net.bnf.idm.oclc.org", + "AUTH_URL_PRESSREADER" : "www-pressreader-com.bnf.idm.oclc.org" }, { "name": "Bibliothèque Publique d'Information (BPI)",