Lister les mises à jour de WordPress
Entrer les lignes suivantes dans la console Javascript du navigateur
{
const names={plugins: "Extensions", themes: "Thèmes", translations: "Traductions"};
let result="";
const getUpgrades = (name) => {
const elements = Array.from(document.querySelectorAll(`[name=\"upgrade-${name}\"] .plugin-title > p > strong`));
if (!elements.length) {
return "";
};
const textContent = elements.map(el => `- ${el.textContent}`).join('\n');
return `${names[name]} :\n${textContent}\n`;
};
for (name in names) {
result = result.concat(getUpgrades(name));
};
console.log(result);
const copyButton = document.createElement("button");
const defaultOpacity = "0.4";
copyButton.style.position = "fixed";
copyButton.style.margin = "20px";
copyButton.style.bottom = "0";
copyButton.style.zIndex = "10";
copyButton.style.backgroundColor = "teal";
copyButton.style.color = "wheat";
copyButton.style.fontSize = "1.5em";
copyButton.style.fontWeight = "bold";
copyButton.style.borderRadius = "10px";
copyButton.style.transition = "all 0.4s 0.1s ease-in";
copyButton.style.opacity = defaultOpacity;
copyButton.onmouseover = function () {
this.style.opacity = "1";
this.style.boxShadow = "black -3px 2px 6px";
this.style.transform = "translate(3px, -2px)";
};
copyButton.onmouseleave = function () {
this.style.opacity = defaultOpacity;
this.style.boxShadow = "unset";
this.style.transform = "translate(-3px, 2px)";
};
copyButton.innerHTML = "Copier la liste";
document.body.insertBefore(copyButton, document.body.firstChild);
const copyFunction = () => {
navigator.clipboard.writeText(result).then(
() => {
console.log("Données copiées dans le presse-papier.");
},
(e) => {
console.error("Les données ne sont pas copiées…", e);
}
);
};
copyButton.addEventListener("click", copyFunction);
}
Version Bookmarklet
Pour une utilisation régulière, il faut ajouter un marque-page, puis remplacer l'URL par le code suivant :
javascript: const names={plugins: "Extensions", themes: "Thèmes", translations: "Traductions"}; let result=""; const getUpgrades = (name) => { const elements = Array.from(document.querySelectorAll(`[name=\"upgrade-${name}\"] .plugin-title > p > strong`));if (!elements.length) {return "";};const textContent = elements.map(el => `- ${el.textContent}`).join('\n');return `${names[name]} :\n${textContent}\n`;};for (name in names) {result = result.concat(getUpgrades(name));};console.log(result);const copyButton = document.createElement("button");const defaultOpacity = "0.4";copyButton.style.position = "fixed";copyButton.style.margin = "20px";copyButton.style.bottom = "0";copyButton.style.zIndex = "10";copyButton.style.backgroundColor = "teal";copyButton.style.color = "wheat";copyButton.style.fontSize = "1.5em";copyButton.style.fontWeight = "bold";copyButton.style.borderRadius = "10px";copyButton.style.transition = "all 0.4s 0.1s ease-in";copyButton.style.opacity = defaultOpacity;copyButton.onmouseover = function () {this.style.opacity = "1";this.style.boxShadow = "black -3px 2px 6px";this.style.transform = "translate(3px, -2px)";};copyButton.onmouseleave = function () {this.style.opacity = defaultOpacity;this.style.boxShadow = "unset";this.style.transform = "translate(-3px, 2px)";};copyButton.innerHTML = "Copier la liste";document.body.insertBefore(copyButton, document.body.firstChild);const copyFunction = () => {navigator.clipboard.writeText(result).then(() => {console.log("Données copiées dans le presse-papier.");},(e) => {console.error("Les données ne sont pas copiées…", e);});};copyButton.addEventListener("click", copyFunction);
Ensuite, le fait de cliquer sur le marque-page activera le script.
En ajoutant comme seul mot-clé : bm_wp
, cela me permet d'entrer ce mot-clé lorsque je suis sur la page de mise à jour de WordPress pour lancer directement le script.
Pas de commentaires