无法访问 twitch DOM
can't access twitch DOM
我刚刚尝试将 twitch.tv 聊天移到左侧,因为在左侧阅读聊天会更舒服。
我在 tampermonkey 中使用了这个脚本:
document.addEventListener("DOMContentLoaded", function(event) {
var rightcol = document.getElementById('right_col');
rightcol.style.right = "";
rightcol.style.left = 0;
});
我在文档末尾将脚本设置为 运行,它 运行s,但控制台显示,我无法访问 null 的 'style'。然后我检查了页面源,也找不到 ID 为 'right_col' 的 div。
该网站似乎是用js脚本构建的...
如何访问 ID 为 'right_col' 的 div 并更改其样式?
解法:
感谢 emmaaaah,我现在使用 chrome stylebot 扩展和这个 css 将 twitch 聊天移到左侧:
#right_col {
right: initial ;
left: 0 ;
}
#main_col, #left_col {
left: initial ;
right: 0 ;
margin-left: 340px;
}
更新 2:
我终于完成了我的更改。聊天现在在左侧,菜单在右侧,所有内容现在都有右边距。
我已经在 github 上提供了我的东西,如果其他人也想要他的抽搐流在左侧:
https://github.com/wullxz/twitchCssAdaptions
尝试使用 Chrome StyleBot 扩展并在其中创建样式,例如
.right_col {
right: initial !important;
left: 0 !important;
}
$('#right_col')[0].style.right = '';
$('#right_col')[0].style.left = 0;
为什么不直接在控制台中写这个?
更新代码:
var moveLeft = function(){
var target = $('#right_col')[0];
if(typeof target === 'undefined'){
setTimeout(function(){
moveLeft();
}, 30 );
}else{
target.style.right = '';
target.style.left = 0;
}
};
moveLeft();
我刚刚尝试将 twitch.tv 聊天移到左侧,因为在左侧阅读聊天会更舒服。
我在 tampermonkey 中使用了这个脚本:
document.addEventListener("DOMContentLoaded", function(event) {
var rightcol = document.getElementById('right_col');
rightcol.style.right = "";
rightcol.style.left = 0;
});
我在文档末尾将脚本设置为 运行,它 运行s,但控制台显示,我无法访问 null 的 'style'。然后我检查了页面源,也找不到 ID 为 'right_col' 的 div。
该网站似乎是用js脚本构建的...
如何访问 ID 为 'right_col' 的 div 并更改其样式?
解法:
感谢 emmaaaah,我现在使用 chrome stylebot 扩展和这个 css 将 twitch 聊天移到左侧:
#right_col {
right: initial ;
left: 0 ;
}
#main_col, #left_col {
left: initial ;
right: 0 ;
margin-left: 340px;
}
更新 2:
我终于完成了我的更改。聊天现在在左侧,菜单在右侧,所有内容现在都有右边距。
我已经在 github 上提供了我的东西,如果其他人也想要他的抽搐流在左侧:
https://github.com/wullxz/twitchCssAdaptions
尝试使用 Chrome StyleBot 扩展并在其中创建样式,例如
.right_col {
right: initial !important;
left: 0 !important;
}
$('#right_col')[0].style.right = '';
$('#right_col')[0].style.left = 0;
为什么不直接在控制台中写这个?
更新代码:
var moveLeft = function(){
var target = $('#right_col')[0];
if(typeof target === 'undefined'){
setTimeout(function(){
moveLeft();
}, 30 );
}else{
target.style.right = '';
target.style.left = 0;
}
};
moveLeft();