Discord Enhancements

Enhance your Discord experience

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Discord Enhancements
// @description Enhance your Discord experience
// @version 5.0
// @namespace https://example.com/
// @match https://*.discord.com/*
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// ==/UserScript==

// Add 3D background
GM_addStyle(`
body {
  background: linear-gradient(45deg, #555, #000);
  background-size: 400% 400%;
  animation: gradient 10s ease infinite;
}

@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
`);

// Add custom styles to elements
GM_addStyle(`
/* Remove top banner */
.headerWrapper-1RvfRv {
  display: none;
}

/* Make user list and chat take up full height */
.container-3baos1 {
  height: 100%;
}

.contentRegion-3nDuYy {
  height: calc(100% - 64px);
}

/* Hide server list and channels */
.sidebar-2K8pFh {
  display: none;
}
`);

// Add translation button to messages
GM_addStyle(`
.message-2qnXI6:hover .translationButton {
  display: inline-block;
}

.translationButton {
  display: none;
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  background-color: #7289da;
  border-radius: 4px;
  cursor: pointer;
}
`);

// Get API key from user
const apiKey = prompt('API Key:');

// Translate message
function translateMessage(message, callback) {
  const sourceLang = 'auto';
  const targetLang = 'en';
  const url = `https://translation.googleapis.com/language/translate/v2?key=${apiKey}&q=${message}&source=${sourceLang}&target=${targetLang}`;
  GM_xmlhttpRequest({
    method: 'GET',
    url: url,
    onload: function(response) {
      const data = JSON.parse(response.responseText);
      const translation = data.data.translations[0].translatedText;
      callback(translation);
    }
  });
}

// Add translation button to each message
const messages = document.querySelectorAll('.markup-2BOw-j');
messages.forEach(function(message) {
  const button = document.createElement('div');
  button.textContent = 'Translate';
  button.classList.add('translationButton');
  button.addEventListener('click', function() {
    const originalMessage = message.textContent;
    translateMessage(originalMessage, function(translation) {
      alert(`Translation: ${translation}`);
    });
  });
  message.appendChild(button);
});