No Caps

Makes stuff with all caps lowercase

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         No Caps
// @namespace    https://greasyfork.org/en/scripts/22856-no-caps
// @version      1.0
// @description  Makes stuff with all caps lowercase
// @author       abbott
// @match        *://*/*
// ==/UserScript==

window.onload = function() {
  var elements = document.body.getElementsByTagName('*');

  for (var i = 0, element;  element = elements[i]; i++) {
    var text = '';
    element.innerHTML.split(/(<.+?>)/).forEach(function(s) {
      text += s.charAt(0) === '<' ? s : noCaps(s);
    });

    element.innerHTML = text;
  }
};

// enforces proper capitalization, lowercases words with all caps
function noCaps(s) {
  return s.split(' ').map(function(word) {
    var caps = 0;

    for (var i = 0, char; char = word.charAt(i); i++) {
      if (char !== char.toLowerCase()) {
        caps++;
      }
    }

    if (caps === (word.length - nonAlpha(word))) {
      return word.toLowerCase();  
    }
    
    return word;
  }).join(' ');
}

function nonAlpha(s) {
  var count = 0;

  for (var i = 0, char; char = s.charAt(i); i++) {
    count += (char.toUpperCase() === char.toLowerCase()) ? 1 : 0; // non letters would return the same result
  }

  return count;
}