somsakul.com

ทดลองทำสิ่งต่างๆ ทั่วไป

ก๊อปไปวางได้เลยใน Violentmonkey

  • VanillaJS
  • มันมี token แต่ไม่รู้ไว้ทำไม ไม่ได้ regen อ่ะ คงเก็บสถิติเฉยๆ
  • หน้าวิดีโอมันใช้เซิฟเวียดนาม ไม่รู้ทำไม

// ==UserScript==
// @name        adintrend.tv
// @namespace   Violentmonkey Scripts
// @icon        https://www.adintrend.tv/favicon.ico
// @version     1.0.0
//
// @match       https://www.adintrend.tv/hd/*
// @grant       GM_addStyle
//
// @author      -
// @description
// ==/UserScript==
GM_addStyle(`
  a.ch-btn {
    color: #888;
    background: #444;
  }
  a.ch-btn:hover {
    color: #444;
    background: lime;
  }
`);
const vdo = document.querySelector('iframe');
const token = document.querySelector("#SecureToken")

vdo.id = 'vdo';
// vdo wrapper

const vdoDiv = document.createElement('div');
vdoDiv.id = 'vdo-div'
vdoDiv.style = 'width:100%;text-align:center;margin-top:2em;'
vdoDiv.appendChild(vdo)

document.body.prepend(vdoDiv);
vdo.after(token);

const tvLinks = Array.from(document.querySelectorAll('a.linktv2')).map(a => {
    return {
        href: a.href,
        text: a.textContent.trim()
    };
});

const newContainer = document.createElement('div');
newContainer.className = 'my-custom-tv-list';
newContainer.style.margin = '10px 0'; // แต่ง Style ตามใจชอบ

tvLinks.forEach(item => {
    const newLink = document.createElement('a');
    newLink.href = item.href;
    newLink.textContent = `${item.text}`; // ใส่ Emoji เพิ่มความสวยงาม
    newLink.className = 'ch-btn';
    newLink.style.marginRight = '5px';
    newLink.style.padding = '5px 5px';
    newLink.style.textDecoration = 'none';
    newLink.style.borderRadius = '5px';

    // ยัดปุ่มใหม่ใส่ใน Container
    newContainer.appendChild(newLink);
});

    // 5. เอา Container ใหม่ไปต่อท้าย Iframe ทันที!
vdo.after(newContainer);

// remove junk
document.querySelector("body > table").remove()

// auto play

const myIframe = document.querySelector('iframe#vdo');

if (myIframe) {
    // รอให้ iframe โหลดเนื้อหาข้างในเสร็จก่อน
    myIframe.addEventListener('load', () => {
        try {
            // 2. เจาะเข้าไปดึงแท็ก <video> ที่อยู่ข้างใน iframe
            const iframeDocument = myIframe.contentDocument || myIframe.contentWindow.document;
            const videoElement = iframeDocument.querySelector('video');

            if (videoElement) {
                // 3. สั่งเล่นวิดีโอทันที!
                setTimeout(function(){
                  videoElement.play();
                  console.log('สั่ง Play วิดีโอใน iframe สำเร็จแล้ว! 🎬');
                },200)
            }
        } catch (error) {
            console.error('เกิดข้อผิดพลาดในการเข้าถึง iframe:', error);
        }
    });
}