You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UnblockReview/modules/UnblockReview.js
+13-22Lines changed: 13 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -60,36 +60,27 @@ export class UnblockReview {
60
60
thrownewError('Searching for target text failed!');
61
61
}
62
62
63
-
// Loop through all the potential matches, and peek at the characters in front of the match. Eliminate false positives ({{tlx|unblock}}, the same text not anywhere near an {{unblock}} template, etc.). If a true positive, return the beginning of the template.
63
+
// Loop through all the potential matches, trying to find an {{Unblock template. If found, return the beginning of the template.
64
64
for(constmatchofmatches){
65
-
// The position of the match within the wikicode.
66
-
constMatchPos=match.index;
67
-
// The position of the unblock template of that match within the wikicode. Set them equal initially. Will be adjusted below.
68
-
letUnblockTemplateStartPos=MatchPos;
69
-
70
-
// check for {{tlx|unblock. if found, this isn't what we want, skip.
// Stop at the beginning of the string OR after 50 characters
70
+
conststopPos=Math.max(0,matchPos-50);
71
+
for(leti=matchPos;i>stopPos;i--){
72
+
if(wikitext[i]==='{'&&wikitext[i-1]==='{'){
73
+
unblockTemplateStartPos=i-1;
74
+
break;
75
+
}
82
76
}
83
77
84
-
// If the above scan couldn't find the beginning of the template within 50 characters of the match, then that wasn't it. Even a long template like `{{Unblock-auto|reason=` isn't 50 characters long. Move on to the next match.
85
-
if(i===50){
78
+
// Don't match stuff that isn't an unblock template
0 commit comments