RageNugget / z00m3r

// ==UserScript==
// @copyright 2018, RageNugget (https://openuserjs.org//users/RageNugget)
// @license MIT
// @name         z00m3r
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       me
// @match        https://pr0gramm.com/*
// @match        http://pr0gramm.com/*
// @grant        GM_addStyle
// @require      http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js
// ==/UserScript==

(function () {
  'use strict';

  var container;
  var streamObserver;

  // wait for page build up
  $(document).ready(function () {
    setTimeout(teil0rInit, 1000);
  });

  function getMainViewObserver() {
    var observer = new MutationObserver(function (changes, observer) {
      $.each(changes, function (index, change) {
        if (change.target.id === 'main-view') {
          if (change.addedNodes && change.addedNodes.length > 0) {
            $.each(change.addedNodes, function (index, node) {
              if (node.id == 'stream') {
                var streamContainer = $('#stream')[0];
                if (streamObserver) {
                  streamObserver.disconnect();
                }
                streamObserver = createItemContainerObserver();
                streamObserver.observe(streamContainer, {
                  childList: true,
                  subtree: true
                });
              }
            });
          }
        }
      });
    });
    observer.observe($('#main-view')[0], {
      childList: true,
      subtree: true
    });

    return observer;
  }

  function teil0rInit() {
    //setup content observer
    var mainViewObserver = getMainViewObserver();

    var streamContainer = $('#stream')[0];
    if (streamContainer) {
      var observer = createItemContainerObserver();
      observer.observe(streamContainer, {
        childList: true,
        subtree: true
      });
    }

  }

  function createItemContainerObserver() {
    var observer = new MutationObserver(function (changes, observer) {
      $.each(changes, function (index, change) {
        if (change.target.className === 'item-container') {
          if (change.addedNodes && change.addedNodes.length > 0) {
            $.each(change.addedNodes, function (index, node) {
              if (node.className === 'item-container-content') {
                $(".item-image").css("height", "auto");
                $(".item-image-actual").css("max-height", "90vh").css("width", "auto").css("display", "block").css("margin", "0 auto").css("position", "relative");
              }
            });
          }
        }
      });
    });
    return observer;
  }

  GM_addStyle('.scrolly{padding-right: 15px; width: 125%; overflow:auto; height: 100%}');
  GM_addStyle('.teilContainer{width: 160px; height: 90vh;border: 1px solid #888; position: fixed; top: 52px; right: 67px; z-index: 10; padding: 11px; overflow: hidden;background-color:rgb(22, 22, 24);}');
  GM_addStyle('.teilThumbImg{width: 100%; height: 100%}');
  GM_addStyle('a.teilThumb{margin-top: 2px; outline: 2px solid #ee4d2e; display: none;}');
  GM_addStyle('a.teilThumb:hover{margin-top: 2px; outline: none;}');
  GM_addStyle('a.noOutline{outline: none;}');
})();