Skip to content

Commit fc88e42

Browse files
author
huupoke12
authored
Fixed infinitive loop causes browser crashes.
The counter in loops is now local, prevent confliction with the others.
1 parent fd82d29 commit fc88e42

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

MinecraftColorCodes.3.7.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
var obfuscators = [];
23
var styleMap = {
34
'§4': 'font-weight:normal;text-decoration:none;color:#be0000',
@@ -23,10 +24,11 @@ var styleMap = {
2324
};
2425
function obfuscate(string, elem) {
2526
var magicSpan,
26-
currNode;
27+
currNode,
28+
len = elem.childNodes.length;
2729
if(string.indexOf('<br>') > -1) {
2830
elem.innerHTML = string;
29-
for(var j = 0, len = elem.childNodes.length; j < len; j++) {
31+
for(var j = 0; j < len; j++) {
3032
currNode = elem.childNodes[j];
3133
if(currNode.nodeType === 3) {
3234
magicSpan = document.createElement('span');
@@ -79,18 +81,17 @@ function parseStyle(string) {
7981
indexDelta,
8082
noCode,
8183
final = document.createDocumentFragment(),
82-
len = codes.length;
83-
i;
84+
len = codes.length,
8485
string = string.replace(/\n|\\n/g, '<br>');
8586

86-
for(i = 0; i < len; i++) {
87+
for(var i = 0; i < len; i++) {
8788
indexes.push( string.indexOf(codes[i]) );
8889
string = string.replace(codes[i], '\x00\x00');
8990
}
9091
if(indexes[0] !== 0) {
9192
final.appendChild( applyCode( string.substring(0, indexes[0]), [] ) );
9293
}
93-
for(i = 0; i < len; i++) {
94+
for(var i = 0; i < len; i++) {
9495
indexDelta = indexes[i + 1] - indexes[i];
9596
if(indexDelta === 2) {
9697
while(indexDelta === 2) {
@@ -126,4 +127,4 @@ String.prototype.replaceColorCodes = function() {
126127
/////////////////////////////////////////////////
127128
function cutString(str, cutStart, cutEnd){
128129
return str.substr(0,cutStart) + str.substr(cutEnd+1);
129-
}
130+
}

MinecraftColorCodes.min.3.7.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)