Commit a2e76cb0 authored by Martin's avatar Martin

- Implement some new settings

 - Remove background color change for thumbnails
parent b889e878
{
"name": "NSFW-plugin",
"version": "1.0",
"description": "Allow flagging images as NSFW",
"description": "Allow hiding images that are NSFW based on tags",
"author": {
"name": "Forecaster",
"link": "http://towerofawesome.org"
......@@ -12,6 +12,21 @@
"label": "Enabled",
"info": "Enable or disable the plugin without loosing data"
},
"conceal_thumbnails": {
"type": "boolean",
"label": "Conceal Thumbnails",
"info": "Hide gallery thumbnails for matching tags"
},
"allow_thumbnail_reveal": {
"type": "boolean",
"label": "Allow Revealing Thumbnails",
"info": "When off thumbnails will appear when hovering the cursor over them"
},
"display_tags": {
"type": "boolean",
"label": "Display Tags",
"info": "Display matching tags over the thumbnail/image"
},
"tags": {
"type": "string",
"label": "Tags",
......
......@@ -16,6 +16,7 @@ class NSFWPlugin extends KokenPlugin
function __construct()
{
$this->require_setup = true;
$this->images_to_hide = array();
$this->pattern_find_caption_first = '/[\S\n\s]*<figcaption>/';
......@@ -54,10 +55,16 @@ class NSFWPlugin extends KokenPlugin
if (!$this->data->enabled)
return $contents;
$tags = json_encode(explode(",", strtolower($this->data->tags)));
$conceal_thumbnails = (($this->data->conceal_thumbnails) ? "true" : "false");
$display_tags = (($this->data->display_tags) ? "true" : "false");
$allow_thumbnail_reveal = (($this->data->allow_thumbnail_reveal) ? "true" : "false");
$script = "
<script>
var tags = JSON.parse('$tags');
var images_to_hide = JSON.parse('$images_to_hide');
var conceal_thumbnails = $conceal_thumbnails;
var display_tags = $display_tags;
var allow_thumbnail_reveal = $allow_thumbnail_reveal;
console.log(tags);
var img_container = document.getElementsByClassName('figimg')[0];
var img_entries = document.getElementsByClassName('content');
......@@ -95,20 +102,23 @@ class NSFWPlugin extends KokenPlugin
tag_section = sections[i];
}
var img_tags = [];
for (var i = 0; i < tag_section.children.length; i++)
if (display_tags)
{
if (tags.indexOf(tag_section.children[i].innerText.toLowerCase()) != -1)
img_tags.push(tag_section.children[i].innerText);
var img_tags = [];
for (var i = 0; i < tag_section.children.length; i++)
{
if (tags.indexOf(tag_section.children[i].innerText.toLowerCase()) != -1)
img_tags.push(tag_section.children[i].innerText);
}
tag_text.innerHTML = '<span style=\'text-transform: capitalize;\'>' + img_tags.join(', ') + '</span>';
}
tag_text.innerText = img_tags.join(', ');
console.info(img_tags);
if (img_tags.length == 0)
child.click();
}
else if (img_entries.length > 0)
else if (img_entries.length > 0 && conceal_thumbnails)
{
console.log(img_entries);
var reg = /\/content\/.*\//g;
......@@ -132,16 +142,17 @@ class NSFWPlugin extends KokenPlugin
div.style.width = '100%';
div.style.height = '100%';
div.style.backgroundColor = 'black';
div.style.transitionProperty = 'background-color, opacity';
div.style.transitionDuration = '10s, 10s';
div.style.transitionDelay = '0s, 2s';
div.style.transitionProperty = 'opacity';
div.style.transitionDuration = '10s';
div.style.transitionDelay = '2s';
div.className = 'cover';
var text = document.createElement('div');
text.style.marginTop = '20px';
text.innerHTML = 'NSFW<br/>';
text.innerHTML += images_to_hide[match];
if (display_tags)
text.innerHTML += '<span style=\'text-transform: capitalize;\'>' + images_to_hide[match] + '</span>';
div.appendChild(text);
a.appendChild(div);
......@@ -149,7 +160,8 @@ class NSFWPlugin extends KokenPlugin
}
var style = document.createElement('style');
style.innerHTML = '.cover:hover { opacity: .5; background-color: red !important; }';
if (allow_thumbnail_reveal)
style.innerHTML = '.cover:hover { opacity: .5; }';
document.head.appendChild(style);
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment