GitHub Reader New

Ajusta automaticamente a largura do GitHub para melhorar a visualização.

  1. // ==UserScript==
  2. // @name GitHub Reader New
  3. // @namespace Violentmonkey Scripts
  4. // @match https://*.github.com/*
  5. // @grant none
  6. // @version 1.7
  7. // @author EmersonxD
  8. // @description Ajusta automaticamente a largura do GitHub para melhorar a visualização.
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Verifica se o estilo já existe antes de criar um novo
  16. if (!document.querySelector('#github-reader-enhancer-style')) {
  17. const style = document.createElement('style');
  18. style.id = 'github-reader-enhancer-style';
  19. document.head.appendChild(style);
  20. }
  21.  
  22. // Define variáveis para valores repetidos
  23. const maxWidth = '100%';
  24. const containerMaxWidth = '90%';
  25.  
  26. // Aplica o CSS personalizado
  27. document.querySelector('#github-reader-enhancer-style').textContent = `
  28. .timeline-new-comment,
  29. .markdown-body {
  30. max-width: ${maxWidth};
  31. }
  32. .markdown-body {
  33. font-size: 1.4em;
  34. }
  35. .discussion-timeline,
  36. .container-lg,
  37. .container-xl {
  38. max-width: ${containerMaxWidth};
  39. }
  40. `;
  41.  
  42. // Função para validar endereços de e-mail
  43. function validateEmail(email) {
  44. const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  45. return re.test(String(email).toLowerCase());
  46. }
  47.  
  48. // Função para enviar e-mails
  49. function sendEmail(subject, body, recipient) {
  50. if (!validateEmail(recipient)) {
  51. alert('O destinatário deve ser um endereço de e-mail válido.');
  52. return;
  53. }
  54.  
  55. if (body.trim() === '') {
  56. alert('O corpo do e-mail não pode estar vazio.');
  57. return;
  58. }
  59.  
  60. const link = `mailto:${recipient}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
  61.  
  62. if (confirm('Tem certeza de que deseja enviar o e-mail?')) {
  63. window.location.href = link;
  64. }
  65. }
  66.  
  67. // Cria o botão de "Salvar e Enviar E-mail"
  68. const saveAndSendBtn = document.createElement('button');
  69. saveAndSendBtn.textContent = 'Salvar e Enviar E-mail';
  70. saveAndSendBtn.style.position = 'fixed';
  71. saveAndSendBtn.style.bottom = '20px';
  72. saveAndSendBtn.style.right = '20px';
  73. saveAndSendBtn.style.zIndex = '9999';
  74. saveAndSendBtn.style.backgroundColor = '#4CAF50';
  75. saveAndSendBtn.style.color = '#fff';
  76. saveAndSendBtn.style.padding = '10px 20px';
  77. saveAndSendBtn.style.borderRadius = '5px';
  78. saveAndSendBtn.style.border = 'none';
  79.  
  80. saveAndSendBtn.addEventListener('click', function() {
  81. const subject = 'Texto salvo do GitHub Reader New';
  82. const body = document.body.innerText;
  83. const recipient = 'testando001245@gmail.com';
  84. sendEmail(subject, body, recipient);
  85. });
  86.  
  87. document.body.appendChild(saveAndSendBtn);
  88. })();