视频解析·书签版(缺少解析地址版)

地址变量为arr,类型为[["地址源名称","地址源"]]

具体代码如下:

const localHost = window.location.href;
const arr = [];
const head = document.querySelectorAll("head")[0];
head.innerHTML=``;
const body = document.querySelectorAll("body")[0];
const list = [];        
arr.forEach((i, n) => {
    const url = i[1] + localHost;
    const div = `<div class="tap" onclick="toNewCinema('${i[0]}')" data-url="${i[1] + localHost}">${i[0]}</div>`;
    list.push(div);
});
body.innerHTML ='';
body.innerHTML=`
<style>
    :root{
        margin: 0;
    }
    body{
        display: flex;
    }
    iframe {
        width: 100vw;
        height: 100vh;
        background-color: #3584f1;
        border: none;
        margin:0;
        position: absolute;
        top:0;
        left:0;
        z-index:1;
    }
    .btn{
        position: fixed;
        top: 400px;
        right: 5px;
        background-color: #2ea968;
        color: #fff;
        width: 40px;
        height: 36px;
        line-height: 36px;
        text-align: center;
        border-radius: 30px;
        cursor: pointer;
        z-index:2;
    }

    .taps {
        position: fixed;
        width: 360px;
        background-color: #2ea968;
        right: 10px;
        font-size: 16px;
        line-height: 36px;
        flex-wrap: wrap;
        top: 400px;
        gap: 10px;
        padding: 20px;
        border-radius: 10px;
        color: #fff;
        display: none;
    }

    .btn:hover .taps{
        display: flex;
    }

    .tap{
        width: 80px;
        height: 36px;
        text-align: center;
        margin:auto;
        background-color: #d44461;
        cursor: pointer;
    }
    .tap:hover{
        background-color: #f1a935;
    }
    .active{
        background-color: #3584f1;
    }

</style>
<div class="btn">
    免
    <div class="taps">${list.join("")}</div>
</div>

<iframe allowtransparency=true frameborder='0' scrolling='no' allowfullscreen=true allowtransparency=true></iframe>
`;
function toNewCinema(context){
        [...document.getElementsByClassName("tap")].forEach(item=>{
            if(item.innerHTML===context){
                item.classList.add("active");
                const url = item.getAttribute("data-url");
                document.querySelectorAll("iframe")[0].setAttribute("src",url)
            }else{
                item.classList.remove("active");
            }
        });
}
toNewCinema(arr[0][0]);

复制该代码,在浏览器中新建书签

粘贴代码需注意先写一个

javascript:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值