简体   繁体   English

Greasemonkey (Violentmonkey) 脚本更改网站值

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

I want to modify the layou of a website:我想修改一个网站的布局:

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

And change " style " to " height: "1080px;并将“样式”更改为“高度:”1080px; width: 1920px;宽度:1920px; " "

Im trying this script, but doesnt work:我正在尝试这个脚本,但不起作用:

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

Whats wrong with it?它出什么问题了?

Why not a simple document.getElementById ?为什么不是一个简单的document.getElementById Try the below code, and see if it helps.试试下面的代码,看看它是否有帮助。 If the setTimeout() had a specific purpose, feel free to include it.如果 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';
}

Hope it helps you out!希望它可以帮助你!

Try inspecting the element.尝试检查元素。 On the Elements tab go the the Styles tab.在元素选项卡 go 上,Styles 选项卡。 From there you should find a checkbox for all the different CSS style rules that are being applied.从那里你应该找到一个用于所有不同 CSS 样式规则的复选框。 Try unchecking the one you do not want and build your script from there.尝试取消选中您不想要的那个并从那里构建您的脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM