gpt4 book ai didi

javascript - 如何使用 greasemonkey 拆分已加载的图片?

转载 作者:行者123 更新时间:2023-11-30 13:40:06 28 4
gpt4 key购买 nike

我正在使用 FireFox。我想将一张图片分成 3 部分,然后使用 greasemonkey 只显示中间部分。有人可以帮帮我吗...谢谢你

最佳答案

您可以通过将图像设置为背景图像并操纵大小和背景位置来实现。

下面是使用 jQuery 的方法:

var img = /* get the image */
var width = Math.round(img.width() / 3.0);

var split = $('<div></div>')
.css('background-image', 'url(' + img.attr('src') + ')')
.css('background-position', '-' + width + 'px 0')
.css('width', width + 'px')
.css('height', img.height());

img.before(split)
.hide();

我假设您想水平拆分它,但将其转换为垂直拆分应该很简单。

参见 this question了解如何在 GreaseMonkey 中使用 jQuery。

关于javascript - 如何使用 greasemonkey 拆分已加载的图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2755614/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com