CFake.com image and link fixer

Prevents links from opening a new window, hides ads, and automatically loads the high res image

01.04.2022 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        CFake.com image and link fixer
// @namespace   cfake.com/*
// @version      1.1
// @description  Prevents links from opening a new window, hides ads, and automatically loads the high res image
// @author       codingjoe
// @match        https://cfake.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

// cut the bs
document.body.onload = function () {};
document.body.style.overflow = "auto";

// xpath
function $x(xpath, root) {
    let doc = root ? root.evaluate ? root : root.ownerDocument : document, next;
    let got = doc.evaluate(xpath, root || doc, null, null, null), result = [];
    while (next = got.iterateNext()) result.push(next);
    return result;
}

(function() {
    'use strict';
    var strMatch = "javascript:showimage('";
    
    // hide ads
    $x("//*[contains(@class, 'footer_style')] | //*[contains(@class, 'display_a_right')]").forEach(ad => {
        ad.style.display = "none";
    });
    
    // enables middle click to open page in new tab
    $x(`//a[contains(@href, "${strMatch}")]`).forEach(link => {
        var pos = link.href.indexOf(".jpg")+4;
        link.href = link.href.substring(strMatch.length, pos);
    })

    // retrieve high res image
    $x("//img[contains(@src, 'medias/photos')]").forEach(img => {        
        if (document.querySelector("img[title='Switch Size']") === null) {
            img.parentNode.href = img.src;
        } else {
            let txt = $x("//script[text()[contains(., 'path_original')]]")[0].innerHTML;
            let pic = /mypicture\s*=\s*'([^']+)';/.exec(txt)[1];
            let path = /path_original\s*=\s*'([^']+)';/.exec(txt)[1];

            let fulllink = `https://cfake.com/${path}${pic}`;
            img.src = fulllink;
            img.parentNode.href = fulllink;
        }
    });
})();