Greasy Fork is available in English.

thejigsawpuzzles.com

enter something useful

  1. /**
  2. * Created by Magnus on 2015-11-07.
  3. */
  4.  
  5. //// ==UserScript==
  6. // @name thejigsawpuzzles.com
  7. // @namespace 4941ca1b-4ea1-42cd-817e-20476bfbae92
  8. // @version 0.25
  9. // @description enter something useful
  10.  
  11. // @match http://thejigsawpuzzles.com/*
  12. // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
  13. // @require https://greatest.deepsurf.us/scripts/9160-my-function-library/code/My%20Function%20library.js?version=93168
  14.  
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @grant GM_deleteValue
  18.  
  19. // @run-at document-start
  20.  
  21. // @created 2015-10-24
  22. // @released 2015-12-10
  23. // @updated 2015-00-00
  24. // @history @version 0.25 - first version: @released - 2015-12-10
  25.  
  26. // @compatible Greasemonkey, Tampermonkey
  27. // @license GNU GPL v3 (http://www.gnu.org/copyleft/gpl.html)
  28. // @copyright 2014+, Magnus Fohlstrom
  29. // ==/UserScript==
  30.  
  31. /*global $, jQuery*/
  32.  
  33. /*jshint -W014, -W030, -W082*/
  34. // -W014, laxbreak, Bad line breaking before '+'
  35. // -W030, Expected assignment or funtion call insted saw an expression
  36.  
  37.  
  38. (function($){
  39.  
  40. var css = {
  41. main : function(){
  42. return ''
  43. + 'img.ImageFrame_solid {'
  44. + 'width: 100%;'
  45. + 'min-width: 130px;'
  46. + 'height: inherit;'
  47. + '}'
  48. + 'img.giThumbnailIce, td#microThumb {'
  49. + 'width: 130px;'
  50. + 'height: inherit;'
  51. + '}'
  52. + '#gallery > table {'
  53. + 'width: calc(100% - 100px);'
  54. + 'margin: 0 auto;'
  55. + '}'
  56. + '#ContentAlbum div.gbNavigator {'
  57. + 'width: 444px ;'
  58. + '}'
  59. + '#sidebar table a {'
  60. + 'font-size: 16px;'
  61. + '}'
  62. + '.popupMenuContainer, #gallery a {'
  63. + 'font-size: 15px !;'
  64. + '}'
  65. + '#gsImageView table {'
  66. + 'zoom:1.5;'
  67. + '}'
  68. + '.buttonAction {'
  69. + 'zoom: 0.3;'
  70. + '}'
  71. + '.buttonAction a {'
  72. + 'height: 60px !;'
  73. + 'width: 60px !;'
  74. + 'background-size: contain !;'
  75. + '}'
  76. + '#gsImageView .buttonAction {'
  77. + 'zoom: 0.6;'
  78. + '}'
  79. + '#gsImageView .buttonAction a {'
  80. + 'height: 12px !;'
  81. + 'width: 12px !;'
  82. + 'background-size: contain !;'
  83. + '}'
  84. + '#gbBlockDownloadEJ {'
  85. + 'background-size: cover !;'
  86. + 'margin: 0 auto;'
  87. + 'width: 222px !;'
  88. + 'height: 212px !;'
  89. + '}'
  90. + 'div#gbBlockDownloadEJ a {'
  91. + 'text-align: center !4;'
  92. + '}';
  93. },
  94. dyn : function(){
  95. return '';
  96. },
  97. style : function( id, var1, var2 ){
  98. var $id = $( 'head #' + id ), cssID = css[ id ]( var1, var2 ).formatString();
  99. $id.length ? $id.html( cssID ) : $( $( '<style/>',{ id: id, class:'mySuperStyles', html: cssID } ) ).appendTo('head');
  100. }
  101. },
  102. html = {
  103. puzzleImageLink : function(){
  104. var $href = location.origin + $('#pg param[name=flashvars]').attr('value').split('URL=').pop().split('%2F').join('\/'),
  105. $html = $( '<a/>',{ class:'gbAdminLink', target:'_blank', href:$href, text:'Link to Image' } );
  106.  
  107. $( '<div/>',{ class:'gbBlock', html:$html } ).appendTo('#gsSidebar');
  108. }
  109. },
  110. fn = {
  111. reSizeImage : function(){
  112. var imgElem = $('body > img'), pageWidth = $w.width(), pageHeight = $w.height(), corr = 0.000,
  113. changeHeight = function(){
  114. imgElem.css('cssText','height:' +( pageHeight - ( pageHeight * corr ) )+ 'px; width: initial');
  115. },
  116. changeWidth = function(){
  117. imgElem.css('cssText','width:' + ( pageWidth - ( pageWidth * corr ) )+ 'px; height: initial');
  118. };
  119.  
  120. imgElem.height() > imgElem.width() ? changeWidth() : changeHeight();
  121. },
  122. loadHref : function( dir ){
  123. var pager = $( '.button' + dir ).find( 'a' ).href();
  124. pager !== undefined && loadDoc( pager );
  125. },
  126. changeThumbLink : function(){
  127. var change = function( $e, find, change ){
  128. $e.attr('src', $e.attr('src').replace( find, change ) );
  129. refreshElement( $e , 'fast' );
  130. };
  131. $( 'img.ImageFrame_solid' ).each(function( i, e ){ change( $(e),'-130/','/' ); });
  132. $( 'img.giThumbnailIce' ).each(function( i, e ){ change( $(e),'-50/','-130' ); });
  133. }
  134. },
  135. listeners = {
  136. pageNav : function(){
  137. c.i('pageNav');
  138. $d.on( 'click', '.gbBlockNavTop, .gbBlockBottom, #gallery', function(e){
  139.  
  140. var X_spot = e.clientX,
  141. ContentElem = $(this).hasId('gallery') ? $('#gallery > table') : $('#ContentAlbum div.gbNavigator table'),
  142. ContentLeft = ContentElem.offset().left,
  143. ContentRight = ContentLeft + ContentElem.width();
  144.  
  145. filterClick( e, this ) && ( X_spot < ContentLeft || X_spot > ContentRight ) &&
  146. fn.loadHref( X_spot < ContentLeft ? 'Prev' : 'Next' );
  147. });
  148. //e.stopPropagation()
  149. //e.preventDefault()
  150. },
  151. keyNav : function(){
  152. d.addEventListener('keydown', function(e){
  153. if( $('input').is(':focus') || g.ms !== 0 ) return false; else g.timer(256);
  154.  
  155. var key = e.keyCode; c.i('Key',key);
  156. switch( key ){
  157. case 39: fn.loadHref( 'Next' ); break; // arrow right
  158. case 37: fn.loadHref( 'Prev' ); break; // arrow left
  159. }
  160. }, false);
  161. },
  162. resize : function(){
  163. c.i('resize');
  164. $w.resize(function(){ $('#feedbackButton').length || fn.reSizeImage(); });
  165. }
  166. },
  167. render = {
  168. first : function(){
  169. c.i('render');
  170. css.style('main');
  171. }
  172. },
  173. observer = new MutationObserver( function( mutations ){
  174. mutations.forEach( function( mutation ){
  175. $( mutation.addedNodes ).each( function( i, e ){
  176. var $e = $(e), $p = $e.parent();
  177. $e.isTag('object') && $e.hasId('pg') && html.puzzleImageLink();
  178. });
  179. });
  180. });
  181.  
  182. //noinspection JSCheckFunctionSignatures
  183. observer.observe( document, { subtree: true, childList: true });
  184.  
  185. render.first();
  186.  
  187. c.i('thejigsawpuzzles.com77');
  188.  
  189. $d.ready(function(){
  190. $('#feedbackButton').length || ( fn.reSizeImage(), listeners.resize() );
  191. fn.changeThumbLink();
  192. listeners.pageNav();
  193. listeners.keyNav();
  194. setTimeout(function(){ $('.mySuperStyles').appendTo('head'); },2000 );
  195. });
  196.  
  197. }(jQuery));