简体   繁体   English

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

[英]Prevent/block/hide images from certain site source

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. If the src of the image is a url that contains the word 'gore', the image is NOT displayed. 如果图像的src是包含单词“ gore”的网址,则不会显示该图像。

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. jQuery对我来说确实是一种外来的“语言”,但这似乎正是我所需要的。 In the code below c_post stands for the actual post, meaning this code targets only images posted inside posts. 在下面的代码中, c_post代表实际的帖子,这意味着该代码仅针对帖子内部发布的图像。 What I want the code to do is select for the word 'gore'. 我要代码执行的操作是选择单词“ gore”。

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

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 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网址重写为您选择的特定图片。

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")

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

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