ct={ // start ct object for Advisor.js fork
noscroll:false, // change to true if your browser's built-in scrolling interferes with the script's scrolling when clicking on a suggestion
rules:[ // begin custom rules
// A ``rule'' is a JavaScript function that accepts a string as a
// parameter (the wikitext of the page being edited) and returns an array
// of ``suggestion'' objects.
function (s) { // example suggestion to replace "int he" with "in the"
var matches = ct.getAllMatches(/int he/g, s);
// getAllMatches() is a custom utility function, you are not required to use it
var suggestions = [];
// A ``suggestion'' object must have the following properties:
// * start---the 0-based inclusive index of the first character to be replaced
// * end---analogous to start, but exclusive
// * (optional) replacement---the proposed wikitext, if any
// * name---this is what appears at the top of the page
// * description---used as a tooltip for the name of the suggestion
// * (optional) help---an HTML fragment as a string, it will appear in a yellow
// box when a suggestion is double-clicked
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
suggestions.push({
start: match.start,
end: match.end,
replacement: "in the",
name: "spelling-example",
description: "You probably meant ``in the'' instead of ``int he''."
});
}
return suggestions;
},
function(s){ // example of function to provide a hint, without a suggested fix
var matches=ct.getAllMatches( /* regular expression to search for */ ,s);
var suggestions=[];
for ( var i = 0 ; i < matches.length ; i++ ) suggestions.push( {
start: matches[i].start,
end: matches[i].end,
name: "example",
description: "example description",
help: "example help text <i>can use HTML</i>", //optional
} );
return suggestions;
}
] // end rules
}; // end ct object
importScript('User:PC-XT/Advisor.js'); // [[User:PC-XT/Advisor]]