Skip to content

Commit c2227ac

Browse files
author
github-actions
committed
Release from Ophirofox v2.4.26329.50904
1 parent 61f0f00 commit c2227ac

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

ophirofox.user.js

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 2.4.26327.43782
2+
// @version 2.4.26329.50904
33
// @author Write
44
// @name OphirofoxScript
55
// @grant GM.getValue
@@ -100,6 +100,7 @@
100100
// @include https://www.monde-diplomatique.fr/*
101101
// @include https://www.courrierdesmaires.fr/*
102102
// @include https://www.la-croix.com/*
103+
// @include https://www.telerama.fr/kiosque/telerama
103104
// @include https://www.courrierinternational.com/*
104105
// @include https://www.lamontagne.fr/*
105106
// @include https://www.humanite.fr/*
@@ -1228,6 +1229,84 @@
12281229
`);
12291230
}
12301231

1232+
if ("https://www.telerama.fr/kiosque/telerama".includes(hostname)) {
1233+
1234+
window.addEventListener("load", function(event) {
1235+
// Function to format date to "YYYY-MM-DD"
1236+
function formatDate(date) {
1237+
const year = date.getFullYear();
1238+
const month = String(date.getMonth() + 1).padStart(2, '0');
1239+
const day = String(date.getDate()).padStart(2, '0');
1240+
return `${year}-${month}-${day}`;
1241+
}
1242+
1243+
// Function to add days to a given date
1244+
function addDays(date, days) {
1245+
const result = new Date(date);
1246+
result.setDate(result.getDate() + days);
1247+
return result;
1248+
}
1249+
1250+
async function onLoad() {
1251+
// Get articles
1252+
const articles = document.querySelectorAll('#liste-magazine-telerama article');
1253+
1254+
for (const article of articles) {
1255+
const linkElement = article.querySelector('a.popin-link');
1256+
const tagName = linkElement.getAttribute('data-tagname');
1257+
const datePattern = /clic_magazine_(\d{4}-\d{2}-\d{2})/;
1258+
const match = tagName.match(datePattern);
1259+
const articleDate = new Date(match[1]);
1260+
// Check if the date object is valid
1261+
if (isNaN(articleDate.getTime())) {
1262+
console.error(`Invalid date: ${year}-${month + 1}-${day}`);
1263+
return;
1264+
}
1265+
// Calculate the new date + 3 days
1266+
const newDate = addDays(articleDate, 3);
1267+
const formattedDate = formatDate(newDate);
1268+
1269+
// Generate the link
1270+
const a = await ophirofoxEuropressePDFLink("TA_P", formattedDate);
1271+
a.classList.add("btn", "btn--premium");
1272+
1273+
// Inject the link into the article
1274+
article.appendChild(a);
1275+
}
1276+
}
1277+
1278+
onLoad().catch(console.error);
1279+
});
1280+
1281+
pasteStyle(`
1282+
.ophirofox-europresse {
1283+
-webkit-font-smoothing: antialiased;
1284+
align-items: center;
1285+
background-color: #ef7c03;
1286+
color: #fff !important;
1287+
display: inline-flex;
1288+
font-family: Public Sans,sans-serif;
1289+
font-size: 12px;
1290+
font-weight: 500;
1291+
height: 15px;
1292+
hyphens: none;
1293+
justify-content: center;
1294+
letter-spacing: 0;
1295+
line-height: 1.35;
1296+
margin: 0 5px;
1297+
position: relative;
1298+
text-align: center;
1299+
top: 50%;
1300+
vertical-align: middle;
1301+
width: 120px;
1302+
}
1303+
1304+
.above-image-wrapper {
1305+
align-items: center;
1306+
}
1307+
`);
1308+
}
1309+
12311310
if ("https://www.courrierinternational.com/*".includes(hostname)) {
12321311

12331312
window.addEventListener("load", function(event) {

0 commit comments

Comments
 (0)