Image BG Toggle

Toggles the background colour for images in the browser

Stan na 23-06-2016. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Image BG Toggle
// @namespace    PXgamer
// @version      0.8
// @description  Toggles the background colour for images in the browser
// @author       PXgamer
// @include      *
// @exclude      *caramel/*
// @require      https://code.jquery.com/jquery-1.12.3.min.js
// @grant        none
// ==/UserScript==
/*jshint multistr: true */

(function() {
    'use strict';

    var allowGrey = false;
    var col = 'black';
    if (document.contentType.indexOf('image') > -1) {
        console.info('IBGT: IS IMAGE');
        $('body').append('<span class="bgToggle" style="left: 95.6%; cursor: pointer; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; z-index: 999999; position: fixed; float: right; background-color: white; border: 1px solid grey; border-radius: 2px; margin: 5px; padding: 2px; font-family: fantasy;">TOGGLE BG</span>');

        $('.bgToggle').on('click', function() {
            if (col == 'black') {
                $('body').css('background-color', col);
                if (allowGrey) { col = 'grey'; }
                else { col = 'white'; }
            }
            else if (col == 'grey') {
                $('body').css('background-color', col);
                col = 'white';
            }
            else if (col == 'white') {
                $('body').css('background-color', col);
                col = 'black';
            }
            else {
                $('body').css('background-color', 'white');
                col = 'black';
            }
        });
    }
})();