custom-admin-script.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. document.addEventListener('DOMContentLoaded', function() {
  2. setTimeout(() => {
  3. if (document.querySelector('.block-editor-writing-flow')) {
  4. setTimeout(() => {
  5. document.querySelector('.rvy-current-status').innerText = replaceText(document.querySelector('.rvy-current-status').innerText);
  6. document.querySelector('.revision-approve.revision-created').innerText = replaceText(document.querySelector('.revision-approve.revision-created').innerText);
  7. let sendButton = document.querySelector('a.revision-approve');
  8. sendButton.addEventListener('click', () => {
  9. setTimeout(() => {
  10. let elToDelete = document.querySelector('.components-panel__row.rvy-creation-ui.edit-post-revision-status')
  11. elToDelete.style.display = "none";
  12. }, 300);
  13. });
  14. }, 500);
  15. } else if (document.querySelector('.revision-q')) {
  16. document.querySelector('.wp-menu-name').innerText = replaceText(document.querySelector('.wp-menu-name').innerText);
  17. document.querySelector('h1').innerText = replaceText(document.querySelector('h1').innerText);
  18. let mine = document.querySelector('.mine a');
  19. if (mine !== null) {
  20. document.querySelector('.mine a').innerText = replaceText(document.querySelector('.mine a').innerText);
  21. }
  22. document.querySelector('#title a').innerText = replaceText(document.querySelector('#title a').innerText);
  23. document.querySelector('#date a').innerText = replaceText(document.querySelector('#date a').innerText);
  24. let sentStatus = document.querySelectorAll('.wp-list-table tbody tr td[data-colname="État"]');
  25. if (sentStatus) {
  26. for (let caseStatus of sentStatus) {
  27. if (caseStatus.firstElementChild.innerText === "Envoyé") {
  28. caseStatus.firstElementChild.innerText = "Envoyé, en attente de validation";
  29. }
  30. }
  31. }
  32. let revisionTitles = document.querySelectorAll('.row-title');
  33. if (revisionTitles) {
  34. for (let revisionTitle of revisionTitles) {
  35. revisionTitle.innerText = revisionTitle.innerText + " (afficher)";
  36. }
  37. }
  38. } else if (document.querySelector('.profile-php')) {
  39. document.querySelector('#toplevel_page_revisionary-q a .wp-menu-name').innerText = replaceText(document.querySelector('#toplevel_page_revisionary-q a .wp-menu-name').innerText);
  40. }
  41. }, 1000);
  42. })
  43. function replaceText(content) {
  44. content = content.replace(/Révision/g, 'Contribution');
  45. content = content.replace(/révision/g, 'contribution');
  46. content = content.replace(/Révisions/g, 'Contributions');
  47. content = content.replace(/révisions/g, 'contributions');
  48. return content;
  49. }