Image BG Toggle

Toggles the background colour for images in the browser

当前为 2016-06-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Image BG Toggle
  3. // @namespace PXgamer
  4. // @version 0.4
  5. // @description Toggles the background colour for images in the browser
  6. // @author PXgamer
  7. // @include *.png*
  8. // @include *.jpg*
  9. // @include *.gif*
  10. // @require https://code.jquery.com/jquery-1.12.3.min.js
  11. // @grant none
  12. // ==/UserScript==
  13. /*jshint multistr: true */
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. var col = false;
  19. $('body').append('<span class="bgToggle" style="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; float: right; background-color: white; border: 1px solid grey; border-radius: 2px; margin: 5px; padding: 2px; font-family: fantasy;">TOGGLE BG</span>');
  20. $('.bgToggle').on('click', function() {
  21. if (!col) {
  22. $('body').css('background-color', 'black');
  23. col = true;
  24. }
  25. else {
  26. $('body').css('background-color', 'white');
  27. col = false;
  28. }
  29. });
  30. })();