Skip to content

Instantly share code, notes, and snippets.

@voldedore
Last active October 2, 2020 07:17
Show Gist options
  • Save voldedore/bb8383d8b867ecba93ffd0db592686f4 to your computer and use it in GitHub Desktop.
Save voldedore/bb8383d8b867ecba93ffd0db592686f4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hide NSFW pictures @ voz
// @namespace voldedore
// @version 0.2
// @author voldedore
// @match https://voz.vn/*
// @require http://code.jquery.com/jquery-1.12.4.min.js
// @grant GM_log
// ==/UserScript==
var $gm = jQuery.noConflict(true);
var minimizedSize = 100;
var btnEventHandle = function () {
}
var init = function () {
var imgs = $gm('img.bbImage');
imgs.each(function (i, img) {
var $imgEl = $gm(img);
// Check original size
//if (img.clientWidth > minimizedSize) {
// Hide the img
$imgEl.attr('style', 'width:' + minimizedSize + 'px');
var imgSrc = $imgEl.attr('src');
// Create new btn
var $btn = $gm('<button data-min="1">');
$btn.html('See');
//$btn.attr('style');
// Handle event
$btn.on('click', function() {
//console.log($btn.attr('data-min'));
if ($btn.attr('data-min') == 1) {
$imgEl.attr('style', 'width: auto');
$btn.html('Hide');
$btn.attr('data-min', 0);
} else {
$imgEl.attr('style', 'width:' + minimizedSize + 'px');
$btn.html('See');
$btn.attr('data-min', 1);
}
});
// Insert btn
var $imgParentDiv = $imgEl.parent();
$btn.insertAfter($imgParentDiv);
//btn.attr('data-img-src', imgSrc);
//}
});
};
(function () {
$gm(function () { init(); });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment