Host Label:
img.yt | imx.to
URL Pattern:
^https?:\/\/([^/]+\.)?(img\.yt|imx\.to)\/(img-[\da-f]+\.html|i\/[\da-z]+)
Search Pattern:
function(pageData, pageUrl) {
var retVal = {imgUrl: null, fileName: null, status: "ABORT"};
pageUrl = pageUrl.replace(/^https:/, "https:");
var postData = "imgContinue=Continue to image ... ";
retVal = httpPost(pageUrl, postData).then(response => {
// Search for <img ... class="centred" ... >
var iTag = (response.pageData.match(/<img\b[^>]*?\bclass\s*=\s*('|")centred\1[^>]*?>/i)||[])[0];
if (iTag) {
var iUrl = (iTag.match(/\bsrc\s*=\s*('|")(.*?)\1/i)||[])[2];
var iName = (iTag.match(/\balt\s*=\s*('|")(.*?)\1/i)||[])[2]; // no extension here
if (iName) { // exists and is not empty
// get extension from iUrl
var extension = iUrl.substring(((iUrl.lastIndexOf(".") - 1) >>> 0) + 2);
if (extension) iName += "." + extension;
}
}
return iUrl ? {imgUrl: iUrl, fileName: iName, status: "OK"} : {status: "ABORT"};
});
return retVal;
function httpPost(pageUrl, postData) {
return new Promise((fulfill, reject) => {
const req = new XMLHttpRequest();
req.onload = function() {
if (this.status === 200) // The request has succeeded.
fulfill({pageData: this.responseText, pageUrl: this.channel.URI.spec});
else reject(this.statusText);
};
req.onerror = function() {
reject(new Error("XMLHttpRequest Error: " + this.statusText));
};
req.open("POST", pageUrl, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
req.send(postData);
});
}
}