阻止/阻止/隐藏某些站点源的图像

时间:2021-07-05 18:55:56

Hey I have a trolling problem at my forum.

嘿,我在论坛上有一个拖钓问题。

Long story short:

长话短说:

There is a troll who comes and posts images from a number of gore sites. In fact this person hotlinks them directly from the source. For obvious reasons, I want to put this to an end.

有一个巨魔来到并发布来自许多戈尔网站的图像。事实上,这个人直接从源头链接他们。出于显而易见的原因,我想结束这一点。

I was thinking of implementing a code that does the following:

我正在考虑实现执行以下操作的代码:

  1. Checks the source of an image before allowing it to load.
  2. 在允许图像加载之前检查图像的来源。

  3. If the src of the image is a url that contains the word 'gore', the image is NOT displayed.
  4. 如果图像的src是包含单词'gore'的url,则不显示图像。

While I realize this isn't a permanent solution, I think this is a step in the right direction. Thoughts? Any idea how I can get started?

虽然我意识到这不是一个永久的解决方案,但我认为这是朝着正确方向迈出的一步。思考?知道如何开始吗?

JQuery is really a foreign "language" to me but it seems like that's what I need. In the code below c_post stands for the actual post, meaning this code targets only images posted inside posts. What I want the code to do is select for the word 'gore'.

JQuery对我来说真的是一种外来的“语言”,但似乎这就是我所需要的。在下面的代码中,c_post代表实际帖子,这意味着此代码仅针对发布在帖子中的图片。我想要的代码是选择'gore'这个词。

$('c_post img[src*="gore"]').attr({ hide(); })

$('c_post img [src * =“gore”]')。attr({hide();})

1 个解决方案

#1


1  

I believe you can accomplish this with a RegEx check

我相信你可以通过RegEx检查完成这项工作

if ( $('c_post img').attr('src').match(/gore/) ) { $('c_post img').attr("src", "filteredimage") }

if($('c_post img')。attr('src')。match(/ gore /)){$('c_post img')。attr(“src”,“filteredimage”)}

If the image's src attribute matches the RegExp, you'd be able rewrite the src url to a specific image of your choice.

如果图像的src属性与RegExp匹配,则您可以将src url重写为您选择的特定图像。

or, if you just want to hide it you could instead do the following inside the if statement:

或者,如果您只想隐藏它,您可以在if语句中执行以下操作:

$('c_post img').css("display", "none")

$('c_post img')。css(“display”,“none”)

#1


1  

I believe you can accomplish this with a RegEx check

我相信你可以通过RegEx检查完成这项工作

if ( $('c_post img').attr('src').match(/gore/) ) { $('c_post img').attr("src", "filteredimage") }

if($('c_post img')。attr('src')。match(/ gore /)){$('c_post img')。attr(“src”,“filteredimage”)}

If the image's src attribute matches the RegExp, you'd be able rewrite the src url to a specific image of your choice.

如果图像的src属性与RegExp匹配,则您可以将src url重写为您选择的特定图像。

or, if you just want to hide it you could instead do the following inside the if statement:

或者,如果您只想隐藏它,您可以在if语句中执行以下操作:

$('c_post img').css("display", "none")

$('c_post img')。css(“display”,“none”)