// UniCyrConv
// version 0.1 BETA!
// 2006-05-06
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script that converts bad unicode cyrillic
// characters to correct ones.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "DumbQuotes", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name UniCyrConv
// @namespace http://eugeni.dodonov.net/projects/unicyrconv/
// @description Transforms bad russian unicode into valid characters
// @include http://www.google.com/bookmarks/*
// ==/UserScript==
//
// --------------------------------------------------------------------
//
//
/* BEGIN LICENSE BLOCK
Copyright (C) 2006 Eugeni Dodonov
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You can download a copy of the GNU General Public License at
http://diveintomark.org/projects/greasemonkey/COPYING
or get a free printed copy by writing to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
END LICENSE BLOCK */
(function() {
var replacements, regex, key, textnodes, node, i, s;
replacements = {
"%u0410":"Ð",
"%u0430":"а",
"%u0411":"Ð",
"%u0431":"б",
"%u0412":"Ð",
"%u0432":"в",
"%u0413":"Ð",
"%u0433":"г",
"%u0414":"Ð",
"%u0434":"д",
"%u0415":"Ð",
"%u0435":"е",
"%u0416":"Ð",
"%u0436":"ж",
"%u0417":"Ð",
"%u0437":"з",
"%u0418":"Ð",
"%u0438":"и",
"%u0419":"Ð",
"%u0439":"й",
"%u041A":"Ð",
"%u043A":"к",
"%u041B":"Ð",
"%u043B":"л",
"%u041C":"Ð",
"%u043C":"м",
"%u041D":"Ð",
"%u043D":"н",
"%u041E":"Ð",
"%u043E":"о",
"%u041F":"Ð",
"%u043F":"п",
"%u0420":"Ð ",
"%u0440":"Ñ",
"%u0421":"С",
"%u0441":"Ñ",
"%u0422":"Т",
"%u0442":"Ñ",
"%u0423":"У",
"%u0443":"Ñ",
"%u0424":"Ф",
"%u0444":"Ñ",
"%u0425":"Ð¥",
"%u0445":"Ñ
",
"%u0426":"Ц",
"%u0446":"Ñ",
"%u0427":"Ч",
"%u0447":"Ñ",
"%u0428":"Ш",
"%u0448":"Ñ",
"%u0429":"Щ",
"%u0449":"Ñ",
"%u042A":"Ъ",
"%u044A":"Ñ",
"%u042B":"Ы",
"%u044B":"Ñ",
"%u042C":"Ь",
"%u044C":"Ñ",
"%u042D":"Ð",
"%u044D":"Ñ",
"%u042E":"Ю",
"%u044E":"Ñ",
"%u042F":"Я",
"%u044F":"Ñ"
};
regex = {};
for (key in replacements) {
regex[key] = new RegExp(key, 'gi');
}
textnodes = document.evaluate(
"//body//text()",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (i = 0; i < textnodes.snapshotLength; i += 1) {
node = textnodes.snapshotItem(i);
s = node.data;
for (key in replacements) {
s = s.replace(regex[key], replacements[key]);
}
node.data = s;
}
})();
//
// ChangeLog
// 2006-05-06 - 0.1 - First version
//