GitHub Reader New

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        GitHub Reader New
// @namespace   Violentmonkey Scripts
// @match       https://*.github.com/*
// @grant       none
// @version     1.7
// @author      EmersonxD
// @description Ajusta automaticamente a largura do GitHub para melhorar a visualização.
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    // Verifica se o estilo já existe antes de criar um novo
    if (!document.querySelector('#github-reader-enhancer-style')) {
        const style = document.createElement('style');
        style.id = 'github-reader-enhancer-style';
        document.head.appendChild(style);
    }

    // Define variáveis para valores repetidos
    const maxWidth = '100%';
    const containerMaxWidth = '90%';

    // Aplica o CSS personalizado
    document.querySelector('#github-reader-enhancer-style').textContent = `
        .timeline-new-comment,
        .markdown-body {
            max-width: ${maxWidth};
        }
        .markdown-body {
            font-size: 1.4em;
        }
        .discussion-timeline,
        .container-lg,
        .container-xl {
            max-width: ${containerMaxWidth};
        }
    `;

    // Função para validar endereços de e-mail
    function validateEmail(email) {
        const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
        return re.test(String(email).toLowerCase());
    }

    // Função para enviar e-mails
    function sendEmail(subject, body, recipient) {
        if (!validateEmail(recipient)) {
            alert('O destinatário deve ser um endereço de e-mail válido.');
            return;
        }

        if (body.trim() === '') {
            alert('O corpo do e-mail não pode estar vazio.');
            return;
        }

        const link = `mailto:${recipient}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;

        if (confirm('Tem certeza de que deseja enviar o e-mail?')) {
            window.location.href = link;
        }
    }

    // Cria o botão de "Salvar e Enviar E-mail"
    const saveAndSendBtn = document.createElement('button');
    saveAndSendBtn.textContent = 'Salvar e Enviar E-mail';
    saveAndSendBtn.style.position = 'fixed';
    saveAndSendBtn.style.bottom = '20px';
    saveAndSendBtn.style.right = '20px';
    saveAndSendBtn.style.zIndex = '9999';
    saveAndSendBtn.style.backgroundColor = '#4CAF50';
    saveAndSendBtn.style.color = '#fff';
    saveAndSendBtn.style.padding = '10px 20px';
    saveAndSendBtn.style.borderRadius = '5px';
    saveAndSendBtn.style.border = 'none';

    saveAndSendBtn.addEventListener('click', function() {
        const subject = 'Texto salvo do GitHub Reader New';
        const body = document.body.innerText;
        const recipient = '[email protected]';
        sendEmail(subject, body, recipient);
    });

    document.body.appendChild(saveAndSendBtn);
})();