Fix PMC Reversed Email

Fix reversed email addresses in PubMed Central

当前为 2023-03-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fix PMC Reversed Email
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Fix reversed email addresses in PubMed Central
  6. // @author Lily Yu
  7. // @match *://*.ncbi.nlm.nih.gov/pmc/articles/*/
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. // Function to reverse a string
  15. function reverseString(str) {
  16. return str.split('').reverse().join('');
  17. }
  18.  
  19. // Find all elements with the class "oemail"
  20. const emailElements = document.querySelectorAll('.oemail');
  21.  
  22. // Iterate through the elements and fix the email address
  23. emailElements.forEach(el => {
  24. // Get the reversed email address from the "data-email" attribute
  25. const reversedEmail = el.getAttribute('data-email');
  26.  
  27. // Reverse the email address
  28. const normalEmail = reverseString(reversedEmail);
  29.  
  30. // Update the "mailto:" link and the displayed text
  31. el.href = `mailto:${normalEmail}`;
  32. el.textContent = normalEmail;
  33. });
  34. })();