jQuery CssDynamic

A dinamic system to customize style css. It append the rules in the end of body

16.01.2017 itibariyledir. En son verisyonu görün.

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://update.greatest.deepsurf.us/scripts/26587/169672/jQuery%20CssDynamic.js

  1. // ==UserScript==
  2. // @author Matteo Burbui @maxeo90
  3. // @name jQuery CssDynamic
  4. // @description A dinamic system to customize style css. It append the rules in the end of body
  5. // @license https://creativecommons.org/licenses/by-sa/4.0/
  6. // @version 1.0
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function( $ ){
  11. $.fn.cssDynamic = function(prop) {
  12. var selector=$(this).selector;
  13. var data,fval,action,idStyle;
  14. if(typeof(prop)=='object'){
  15. fval=1,data='';
  16. for (var k in prop){
  17. if (prop.hasOwnProperty(k)) {
  18. data+=k+':'+prop[k]+';'
  19. }
  20. }
  21. }else if(arguments[1]!=undefined){
  22. fval=2;
  23. data=arguments[0]+':'+arguments[1]
  24. }else if(prop=='remove'){
  25. fval=0;
  26. } else{return 'error'}
  27. action=(arguments[fval]==undefined)?'add':arguments[fval];
  28. idStyle=(arguments[fval+1]==undefined)?'cssDynamic':arguments[fval+1];
  29. switch(action) {
  30. case 'new':
  31. actNew()
  32. break;
  33. case 'add':
  34. actAdd()
  35. break;
  36. case 'remove':
  37. actRemove()
  38. break;
  39. case 'renew':
  40. actRemove()
  41. actNew()
  42. break;
  43. }
  44. function chData(){
  45. data=selector+'{'+data+'}'
  46. }
  47. function actNew(){
  48. chData();
  49. $('body').append('<style id="'+idStyle+'">'+data+'</style>')
  50. }
  51. function actAdd(){
  52. if($('#'+idStyle).length){
  53. actNew()
  54. }else{
  55. chData();
  56. $('style#'+idStyle).append(data)
  57. }
  58. }
  59. function actRemove(){
  60. $('style#'+idStyle).remove();
  61. }
  62. return this;
  63. };
  64. })( jQuery );
  65.