WebAdRule Extra Script

This script is an extension of the Web Ad Rule to fix something that easylist can't handle

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        WebAdRule Extra Script
// @version     1.1.1
// @namespace   http://tampermonkey.net/
// @match       *://*.51cto.com/*
// @match       *://*.segmentfault.com/*
// @match       *://juejin.cn/*
// @grant       GM_addStyle
// @run-at      document-start
// @require     https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
// @author      xndeye
// @description This script is an extension of the Web Ad Rule to fix something that easylist can't handle
// @license MIT
// ==/UserScript==
(function () {
    'use strict';
})();


let domain = null;
function getdomain() {
    if (!domain) {
        domain = document.location.hostname.split('.').slice(-2).join('.')
        console.log('<WebAdRule Extra Script> : ' + domain)
    }
    return domain ? domain : ''
}

/**
 * Inject on document-start
 */
switch (getdomain()) {
    default:
        break;
}

/**
 * Execute after page load
 */
window.onload = function () {
    switch (getdomain()) {
        case '51cto.com':
            setTimeout(function () {
                $(".copy_btn").each(function () {
                    $(this).text('复制');
                    this.setAttribute('class', 'copy-r');
                    this.onclick = function () {
                        var item = $(this.getAttribute('data-clipboard-target'));
                        if (item[0].tagName === 'CODE') {
                            navigator.clipboard.writeText(item.text())
                        } else {
                            navigator.clipboard.writeText(item.siblings().text());
                        }
                    }
                });
            }, 1000);
            break;

        case 'juejin.cn':
            document.oncopy = event => event.clipboardData.setData('text', window.getSelection(0).toString());
            $('a[href]').each(function () {
                console.log($(this).html());
                let link = $(this).attr('href').replace('https://link.juejin.cn?target=', '');
                if (typeof link !== 'undefined') {
                    $(this).attr('href', decodeURIComponent(link));
                }
            })
            break;

        case 'segmentfault.com':
            $('.article a[href]').each(function () {
                if ($(this).attr('href').startsWith('https://link.segmentfault.com')) {
                    $(this).attr('href', $(this).text());
                }
            })
            break;

        default:
            break;
    }
}