Ab Link
Ab Link
Ab Link
// This script solves Ablink images with words and having 3 or 4 different options
// Number identification logic for comparing words and numbers will be implemented
in the next versions
// Accuracy can be improved by adding more filters for different types of images
and fonts
// This script does not have a global matcher, you will need to add the websites in
the matcher section manually, till
// all the solutions are implemented
// Your account will be locked for 24 hours, if 3 incorrect solutions are provided
consecutively in 10 minutes. (This is the default but depends on website)
// To avoid this add a rotator to change the website whenever an incorrect solution
is provided.
if (pixelAtPosition == 0xFF000000){
if(noiseCount == 0){
noiseRowStart = row;
}
noiseCount++;
}else{
//Define the number of consecutive pixels to be considered
as noise
if(noiseCount > 0 && noiseCount <= threshold){
//Start from noiseRow till current row and remove noise
while(noiseRowStart < row){
let noisePosition = noiseRowStart * width + column;
imgdata[noisePosition] = 0xFFFFFFFF;
noiseRowStart++;
}
}
noiseCount =0;
}
}
}
return resolve(imgdata);
})
if (!image || !image.src) {
console.log("No images found");
return;
}
//console.log( c.toDataURL());
let imageDataURI = await toDataURL(c);
return await (imageUsingOCR(imageDataURI));
}
if (!image || !image.src) {
console.log("No images found");
return;
}
var c = document.createElement("canvas")
c.width = img.width;
c.height = img.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
//console.log(await c.toDataURL());
var imageData = await ctx.getImageData(0, 0, c.width, c.height);
var data = await imageData.data;
if ((data[i] < 100 || data[i + 1] < 100 || data[i + 2] < 100) &&
data[i+3]>0) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
}
data[i + 3] = 255;
}
//console.log( c.toDataURL());
let imageDataURI = await toDataURL(c);
return await (imageUsingOCR(imageDataURI));
}
if (!image || !image.src) {
console.log("No images found");
return;
}
var c = document.createElement("canvas")
c.width = img.width;
c.height = img.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
//console.log(await c.toDataURL());
var imageData = await ctx.getImageData(0, 0, c.width, c.height);
var data = await imageData.data;
if ((data[i] > 100 || data[i + 1] > 100 || data[i + 2] > 100) && data[i
+ 3] > 0) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
}
data[i + 3] = 255;
}
var c = document.createElement("canvas")
c.width = img.width;
c.height = img.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
//console.log(await c.toDataURL());
var imageData = await ctx.getImageData(0, 0, c.width, c.height);
var data = await imageData.data;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
}
data[i + 3] = 255;
}
if(answerImagesLength == 3){
return await splitImageByThree(imageDataURI);
}
var c = document.createElement("canvas")
c.width = img.width;
c.height = img.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
//console.log(await c.toDataURL());
var imageData = await ctx.getImageData(0, 0, c.width, c.height);
var data = await imageData.data;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
}
data[i + 3] = 255;
}
var c = document.createElement("canvas")
c.width = img.width;
c.height = img.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
//console.log(await c.toDataURL());
if ((data[i] > 100 || data[i + 1] > 100 || data[i + 2] > 100) && data[i
+ 3] > 0) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
}
data[i + 3] = 255;
}
if(answerImagesLength == 3){
return await splitImageByThree(imageDataURI);
}
//console.log(await c.toDataURL());
sequenceLength = 0;
}
prevColumn = column;
Jimp.read(buffer).then(async function(data) {
await data.crop(0, 0, columnArray[0], questionImage.height)
.getBase64(Jimp.AUTO, async function(err, src) {
let img = new Image();
img.crossOrigin = 'anonymous';
img.src = src
await waitForImage(img);
questionImages[0] = img;
resolve();
})
});
});
})
});
});
})
});
});
//console.log(await c.toDataURL());
sequenceLength = 0;
}
prevColumn = column;
Jimp.read(buffer).then(async function(data) {
await data.crop(0, 0, columnArray[0], questionImage.height)
.getBase64(Jimp.AUTO, async function(err, src) {
let img = new Image();
img.crossOrigin = 'anonymous';
img.src = src
await waitForImage(img);
questionImages[0] = img;
resolve();
})
});
});
})
});
});
if (!image || !image.src) {
console.log("No images found");
return;
}
src.delete();
dst.delete();
//console.log( c.toDataURL());
let imageDataURI = await toDataURL(c);
var c = document.createElement("canvas")
c.width = img1.width;
c.height = img1.height;
var ctx = c.getContext("2d");
if (hashMap.has(rgba)) {
hashMap.set(rgba, hashMap.get(rgba) + 1)
} else {
hashMap.set(rgba, 1)
}
if (data[i + 3] > 130 && data[i] < 100 && data[i + 1] < 100 && data[i +
2] < 100) {
data[i] = 0;
data[i + 1] = 0;
data[i + 2] = 0;
data[i + 3] = 255;
data_tmp_edges[i] = 1;
data_tmp_edges[i + 1] = 1;
data_tmp_edges[i + 2] = 1;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
data[i + 3] = 255;
}
}
await ctx.putImageData(imageData, 0, 0);
var c = document.createElement("canvas")
c.width = image.width;
c.height = image.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
var imageData = await ctx.getImageData(0, 0, c.width, c.height);
var data = await imageData.data;
// console.log(data);
src.delete();
dst.delete();
M.delete();
// console.log( c.toDataURL());
var c = document.createElement("canvas")
c.width = image.width;
c.height = image.height;
var ctx = c.getContext("2d");
await ctx.drawImage(img, 0, 0);
var imageData = await ctx.getImageData(0, 0, c.width, c.height);
var data = await imageData.data;
// console.log(data);
//Image erode
src = await cv.imread(c);
M = cv.Mat.ones(2, 1, cv.CV_8U);
await cv.erode(src, dst, M, anchor, 1, cv.BORDER_CONSTANT,
cv.morphologyDefaultBorderValue());
await cv.imshow(c, dst);
src.delete();
dst.delete();
M.delete();
// console.log( c.toDataURL());
let imageDataURI = await toDataURL(c);
if (hashMap.has(rgba)) {
hashMap.set(rgba, hashMap.get(rgba) + 1)
} else {
hashMap.set(rgba, 1)
}
var maxCount = 0;
var objectKey = "0,0,0,0";
await hashMap.forEach((value, key) => {
if (maxCount < value && key != "0,0,0,0") {
objectKey = key;
maxCount = value;
}
});
if (data[i + 3] == alpha) {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
data[i + 3] = 255;
//Giving some value for representation
data_tmp[i] = 1;
data_tmp[i + 1] = 1;
data_tmp[i + 2] = 1;
} else {
data[i] = 255;
data[i + 1] = 255;
data[i + 2] = 255;
data[i + 3] = 255;
}
}
//console.log(imageData.data);
await ctx.putImageData(imageData, 0, 0);
// console.log( c.toDataURL());
let imageDataURI = await toDataURL(c);
if (!worker) {
worker = await new Tesseract.createWorker();
}
try {
await worker.load();
await worker.loadLanguage('eng');
await worker.initialize('eng');
await worker.setParameters({
tessedit_pageseg_mode: '6',
preserve_interword_spaces: '1',
tessedit_char_whitelist:
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,@!*+',
//tessedit_ocr_engine_mode:'1'
});
// await worker.terminate();
} catch (err) {
console.log(err.message);
await worker.terminate();
return answer;
return matrix[b.length][a.length];
};
return count;
}
ocrResult = tempResult;
return ocrResult;
if(window.location.href.includes("gr8.cc")){
var oldFunction = unsafeWindow.open;
unsafeWindow.open= function(url){url = url.split("?r=")[0] + "?
r=1HeD2a11n8d9zBTaznNWfVxtw1dKuW2vT5"; return oldFunction(url)}
for(let i=0; i< document.querySelectorAll("a").length;i++){
document.querySelectorAll("a")[i].removeAttribute("onmousedown");
document.querySelectorAll("a")[i].href= document.querySelectorAll("a")
[i].href.split("?r=")[0] + "?r=1HeD2a11n8d9zBTaznNWfVxtw1dKuW2vT5";
}
}
setTimeout(async function() {
if (document.querySelector(questionSelector).width < 10 *
document.querySelector(questionSelector).height) {
leastLength = 2;
} else {
leastLength = 3;
}
console.log("Solving Ab Links....");
if (!document.querySelector(questionSelector) || !
document.querySelector(questionSelector).src) {
document.querySelector(answerSelector).value = "####"; //Using this as
reference to move to next url
console.log("No image source found for question");
return
}
questionImage = document.querySelector(questionSelector);
questionImageSource = document.querySelector(questionSelector).src;
await waitForImage(questionImage);
var optionImages = [];
if (!questionSolution || !questionSolution.includes(",") ||
questionSolution.split(",").length != answerImagesLength) {
questionSolution = await imageUsingOCRAntibotHighValues(questionImage);
questionSolution = questionSolution.replace(/,$/, "");
}
if (!questionSolution || !questionSolution.includes(",") ||
questionSolution.split(",").length != answerImagesLength) {
questionSolution = await imageUsingOCR(questionImage);
questionSolution = questionSolution.replace(/,$/, "");
}
if (!questionSolution || !questionSolution.includes(",") ||
questionSolution.split(",").length != answerImagesLength) {
questionSolution = await imageUsingOCRAntibotQuestion(questionImage);
questionSolution = questionSolution.replace(/,$/, "");
}
if (!questionSolution || !questionSolution.includes(",") ||
questionSolution.split(",").length != answerImagesLength) {
await splitImageUsingDefaultValues(questionImageSource,
answerImagesLength);
if(questionImages.length < answerImagesLength){
questionImages = [];
await splitImageUsingOCRAntibotLowValues(questionImageSource,
answerImagesLength);
}
questions[i] = await
getFinalOCRResultFromImage(questionImages[i],leastLength);
questions[i] = questions[i].replaceAll("5", "s").replaceAll("3",
"e").replaceAll(",", "")
.replaceAll("8", "b").replaceAll("1", "l").replaceAll("@",
"a").replaceAll("*", "").replaceAll("9", "g")
.replaceAll("!", "i").replaceAll("0", "o").replaceAll("4",
"a").replaceAll("2", "z").toLowerCase();
}
} else {
questionSolution = questionSolution.toLowerCase();
questionSolution = questionSolution.replaceAll("5",
"s").replaceAll("3", "e")
.replaceAll("8", "b").replaceAll("1", "l").replaceAll("@",
"a").replaceAll("*", "").replaceAll("9", "g")
.replaceAll("!", "i").replaceAll("0", "o").replaceAll("4",
"a").replaceAll("2", "z").toLowerCase();
questions = questionSolution.split(',');
}
leastLength = 1000;
for (let i = 0; i < answerImagesLength; i++) {
if (questions[i].length < leastLength) {
leastLength = questions[i].length;
}
}
leastLength = leastLength - 1;
await worker.terminate();
if (questions.length == answerImagesLength) {
map[Symbol.iterator] = function*() {
yield*[...this.entries()].sort((a, b) => a[1] - b[1]);
}
if (preValue == value) {
tempMap.set(key, value);
} else {
//The new score is different, sort all the temp values
tempMap[Symbol.iterator] = function*() {
yield*[...this.entries()].sort((a, b) => a[0] - b[0]);
}
if (count == map.size) {
tempMap.set(key, value);
tempMap[Symbol.iterator] = function*() {
yield*[...this.entries()].sort((a, b) => a[0] - b[0]);
}
}, 10000)
})();