簡體   English   中英

Greasemonkey (Violentmonkey) 腳本更改網站值

[英]Greasemonkey (Violentmonkey) script to change website value

我想修改一個網站的布局:

<div id="fluid_video_wrapper_video-id" class="fluid_video_wrapper fluid_player_layout_default" style="height: 150px; width: 300px;">

並將“樣式”更改為“高度:”1080px; 寬度:1920px; "

我正在嘗試這個腳本,但不起作用:

var query = document.querySelector("#fluid_video_wrapper_video-id");
if (query) {
    window.setTimeout(function(){
        query.setAttribute("style", "height: 1080px; width: 1920px;");
      
    }, 500)
}

它出什么問題了?

為什么不是一個簡單的document.getElementById 試試下面的代碼,看看它是否有幫助。 如果 setTimeout() 有特定目的,請隨意包含它。

//grab the id of the div
const modify = document.getElementById('fluid_video_wrapper_video-id');

//if it exists
if (modify) {
     //style the width and height
     modify.style.height = '1080px';
     modify.style.width = '1920px';
}

希望它可以幫助你!

嘗試檢查元素。 在元素選項卡 go 上,Styles 選項卡。 從那里你應該找到一個用於所有不同 CSS 樣式規則的復選框。 嘗試取消選中您不想要的那個並從那里構建您的腳本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM