jc_Page_Down

Click to Next Scroll Page && Easy to View.

  1. // ==UserScript==
  2. // @name jc_Page_Down
  3. // @namespace http://localhost/jc/
  4. // @.require https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js
  5. // @.require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
  7. // @.require http://192.168.10.15/files/jquery-1.8.3.min.js
  8. // @.require http://192.168.10.15/files/jquery-1.11.0.min.js
  9. // @include http://*/forum.php?mod=viewthread*
  10. // @include http://*/forum/thread-*
  11. // @include http://*/*/viewthread.php*
  12. // @include http://*/*/forum*
  13. // @include http://weibo.com/*
  14. // @include http://www.flickr.com/*
  15. // @include http://www.google.co*/search?*
  16. // @include https://www.google.co*/search?*
  17. // @include http://www.upskirtcollection.com/*
  18. // @include http://www.akiba-online.com/*
  19. // @include http://*
  20. // @include https://*
  21. // @exclude https://*.pchome.com.tw/*
  22. // @exclude https://*.yahoo.com*
  23. // @exclude https://*.gohappy.com.tw/*
  24. // @exclude http://jsfiddle.net/*
  25. // @exclude http://localhost/*
  26. // @exclude http://localhost:*
  27. // @exclude http://*.tumblr.com/*
  28. // @exclude http://*.com/*mod=rss*
  29. // @exclude https://www.youtube.com/*
  30. // @exclude http://msdn.microsoft.com/*
  31. // @exclude http*://www.blogger.com/blogger.g?blogID*
  32. // @exclude http://www.google.com/reader/view/*
  33. // @exclude http://www.google.com.tw/reader/view/*
  34. // @exclude http://jsbin.com/*
  35. // @exclude http://*.gov.tw/*
  36. // @exclude https://*.gov.tw/*
  37. // @exclude http://*/feed/*
  38. // @exclude http://*shopping*
  39. // @exclude http://baike.baidu.com/picture/*
  40. // @exclude http://www.youtube.com/playlist?*
  41. // @exclude http://mall.cheerspoint.com.tw/*
  42. // @exclude http://writecodeonline.com/*
  43. // @exclude http://case.518.com.tw/*
  44. // @exclude http://www.104case.com.tw/*
  45. // @exclude http://yun.baidu.com/*
  46. // @exclude http://vimeo.com/*
  47. // @exclude http://*.html5rocks.com/*
  48. // @exclude http://www.dartlang.*
  49. // @exclude http://192.168.*
  50. // @exclude http://127.0.0.1*
  51. // @exclude https://*.taobao.com/*
  52. // @exclude http://*.taobao.com/*
  53. // @exclude http://*.360.cn/*
  54. // @exclude https://*.360.cn/*
  55. // @exclude https://*.google.co*/*edit
  56. // @exclude https://drive.google.co*/*
  57. // @exclude https://docs.google.com/*
  58. // @exclude http://open.163.com/*
  59. // @exclude https://mail.google.com/*
  60. // @exclude http://jshint.com/
  61. // @exclude https://jshint.com/
  62. // @exclude https://codecombat.com/*
  63. // @exclude http://*.org.tw/*
  64. // @exclude https://*.org.tw/*
  65. // @exclude https://www.google.com/*
  66. // @exclude https://*.google.com/*
  67. // @exclude https://www.google.com.tw/*
  68. // @exclude http://*.baidu.com/*
  69. // @exclude https://*.baidu.com/*
  70. // @exclude https://www.megabank.com.tw/*
  71. // @exclude http://earth.nullschool.net/*
  72. // @exclude https://*.google.co*
  73. // @exclude https://192.168.*
  74. // @exclude http://192.168.*
  75. // @description Click to Next Scroll Page && Easy to View.
  76. // @grant GM_addStyle
  77. // @grant GM_log
  78. // @version 0.5.6
  79. // @modified 2015.02.24.00h
  80. // ==/UserScript==
  81.  
  82. // https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js
  83.  
  84.  
  85. jQuery.noConflict();
  86. (function($) {
  87. $(function() {
  88. //GM_addStyle("#jcBtnPageDown {z-index:99998; background: -moz-linear-gradient(#FFFFFF 0%, #CCCCCC 100%) repeat scroll 0 0 #E5E5E5; border: 1px solid #AAAAAA; border-radius: 4px 4px 4px 4px; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); color: #555555; display:block; width:auto; padding:0px; color:black; }");
  89. //GM_addStyle("#jcBtnPageDown {z-index:99998; border: 1px solid #AAAAAA; border-radius: 4px 4px 4px 4px; color: #555555; display:block; width:auto; padding:0px; }");
  90. GM_addStyle("#jcBtnPageDown { font-size:120%; max-width:80px; z-index:99998; }");
  91. GM_addStyle("#jcBtnPageDown button {border: 1px solid #AAAAAA; border-radius: 4px 4px 4px 4px; color: #555555; display:inline-block; width:auto; padding:0px; font-size:13px; }");
  92. GM_addStyle("#jcBtnPageDown button.hideClass {min-width:15px;}");
  93. var gScrolled = false; // 是否捲動
  94. //var gBtnTopDiffNum = 0; // 按鈕與視窗 Top 差距多少.
  95. var jc_click_last_time = 0; // last click time
  96. $(document).ready(function() { // 動態載入,也會觸發 document ready 事件
  97. //console.log('document ready event!');
  98. jcAppendEvents();
  99. });
  100. function hasClickEvent( jqObj ) {
  101. var elem = jqObj.get(0);
  102. var rule1 = (!('undefined' == typeof $._data( elem, "events" )));
  103. var rule2 = jqObj.attr('onclick');
  104. rule2 = (!((typeof rule2 == 'undefined') || (rule2 == null) || (rule2 == false)));
  105. return (rule1 || rule2);
  106. }
  107. function jcAppendEvents() {
  108. // 事件附加區
  109. //
  110. // Page Scroll Down
  111. $('html,body').on('click' , function(e) {
  112. var runnext = true;
  113. var eTagName = e.target.tagName;
  114. if (0 == $('#jcBtnPageDown').length) {
  115. $('#jcBtnPageDown').hide();
  116. }
  117. if ('' != window.getSelection()) {
  118. //return;
  119. //e.preventDefault();
  120. runnext = false;
  121. }
  122. if (self.location != top.location) {
  123. //return;
  124. //e.preventDefault();
  125. runnext = false;
  126. }
  127. if ( ('DIV' == eTagName) && ($(e.target).attr('sap-media')) ) {
  128. runnext = false;
  129. }
  130. console.log('click element == ' + eTagName );
  131. if (runnext) {
  132. if( ('A' == eTagName) || ('LINK' == eTagName) || ( "BLOCKQUOTE" == eTagName) ||
  133. //("P" == eTagName) ||
  134. ("TEXTAREA" == eTagName ) || ( "INPUT" == eTagName ) ||
  135. ( "SELECT" == eTagName ) || ( "OPTION" == eTagName ) ||
  136. //( "UL" == eTagName ) || ( "LI" == eTagName ) ||
  137. ( "MAP" == eTagName ) || ( "AREA" == eTagName ) ||
  138. ( "CANVAS" == eTagName ) || ( "SVG" == eTagName ) || ( "G" == eTagName ) || ( "LINE" == eTagName ) || ( "RECT" == eTagName ) || ( "TEXT" == eTagName ) ||
  139. ('BUTTON' == eTagName) || ( "IMG" == eTagName ) || ("EMBED" == eTagName ) || ("OBJECT" == eTagName ) || ( "VIDEO" == eTagName ) ) {
  140. runnext = false;
  141. }
  142. }
  143. if (runnext) {
  144. if (('HTML' != eTagName) && ($( e.target ).parents('a').length > 0)) {
  145. runnext = false;
  146. }
  147. }
  148. if (runnext) {
  149. //if ( ($(e.target).width() < 45) || ($(e.target).height() < 45) ) {
  150. if ( ($(e.target).width() < 60) || ($(e.target).height() < 30) ) {
  151. //if ( ($(e.target).width() < 100) || ($(e.target).height() < 100) ) {
  152. console.log('false, because: H = ' + $(e.target).height() + ' W = ' + $(e.target).width() + ' < (60,30)' );
  153. runnext = false;
  154. }
  155. }
  156. if (!runnext) {
  157. if( ('TD' == eTagName) || ('TH' == eTagName) ) {
  158. runnext = true;
  159. }
  160. }
  161. if (runnext) {
  162. // 如果有 handle event , 則放棄
  163. if (('HTML' != eTagName) && hasClickEvent($(e.target))) {
  164. runnext = false;
  165. }
  166. }
  167. if (!runnext) {
  168. if ('BODY' == eTagName) {
  169. runnext = true;
  170. }
  171. }
  172. if (runnext) {
  173. if (0 == $('#jcBtnPageDown').length) {
  174. var insHtml = '<div id="jcBtnPageDown" align="left" style="display:none;">' +
  175. '<button type="button" class="PageDownClass">Page Down</button>' +
  176. '<button type="button" class="ezViewClass">易讀</button>' +
  177. '<button type="button" class="hideClass">-</button>' +
  178. '</div>';
  179. $('body').append(insHtml);
  180. $('#jcBtnPageDown button.PageDownClass').css('max-width' , Math.max(80 , parseInt($('#jcBtnPageDown button.PageDownClass').width() , 10) ) + 'px');
  181. $('#jcBtnPageDown button.PageDownClass').click(function(e) {
  182. jcGetNextScrollTop(e);
  183. //e.stopPropagation();
  184. //e.preventDefault();
  185. });
  186. $('#jcBtnPageDown button.ezViewClass').click(function(e) {
  187. doJcEasyView();
  188. });
  189. $('#jcBtnPageDown button.hideClass').click(function(e) {
  190. //$('#jcBtnPageDown').hide();
  191. $('#jcBtnPageDown').remove();
  192. });
  193. }
  194. //var x = e.pageX - this.offsetLeft - parseInt($('#jcBtnPageDown').width() / 2);
  195. //var y = e.pageY - this.offsetTop - $(window).scrollTop() - parseInt($('#jcBtnPageDown').height() / 2) - 5;
  196. // use position:fixed
  197. var x = e.pageX - this.offsetLeft - 55;
  198. var y = e.pageY - this.offsetTop - $(window).scrollTop() - 13;
  199. console.log( ' W = ' + $(e.target).width() + ' , H = ' + $(e.target).height() );
  200. console.log(' x = ' + x + ' , y = ' + y );
  201. window.setTimeout(function() {
  202. $('#jcBtnPageDown').css('position' , 'fixed')
  203. .css('left' , x + 'px')
  204. .css('top' , y + 'px')
  205. .show();
  206. }, 500);
  207. e.stopPropagation();
  208. e.preventDefault();
  209. }
  210. });
  211. //
  212. }
  213. function jcGetNextScrollTop(e) {
  214. // 取得下一個 scroll down
  215. // 如果有 jcTumblrClickToRemoveThisArticle ,則以其為準
  216. // 沒有則下捲 doc_top + win_h - 180
  217. var t = new Date;
  218. var click_time = t.getTime();
  219. if ((click_time - jc_click_last_time) < 200) { return; }
  220. jc_click_last_time = click_time;
  221. var docTop = $(window).scrollTop(); // document scroll top
  222. var winH = Math.min( $(window).height() , window.innerHeight ); // window hieght
  223. var docH = $(document).height(); // document hieght
  224. var liTop = docTop + winH - 180;
  225. if (docH > winH) { // check window height is correct!?
  226. // 下捲
  227. $(window).scrollTop(liTop);
  228. //GM_log('PageDown: docTop ' + docTop + ' , winH ' + winH + ' , docH ' + docH + ' , liTop ' + liTop);
  229. /*
  230. var y = parseInt($('#jcBtnPageDown').attr('data-y') , 10);
  231. y = y + ($(window).scrollTop() - docTop);
  232. $('#jcBtnPageDown').css('top' , y + 'px')
  233. .attr('data-y' , y);
  234. */
  235. }
  236. liTop = null;
  237. docTop = null;
  238. winH = null;
  239. docH = null;
  240. }
  241. function doJcEasyView() {
  242. // 易讀性
  243. doJcEasyView_v2();
  244. }
  245. function doJcEasyView_v1() {
  246. // 易讀性 v1
  247. (function(){
  248. var winW = Math.min(1700 , parseInt($(window).width() , 10) - 50);
  249. var newSS, styles='* {background:white !important; color:black !important; line-height: 180% !important; font-size: 0.85cm !important; width:auto !important; max-width:' + winW + 'px; margin: 0 0 0 0 !important; } ' +
  250. ':link, :link * { color: #0000EE !important;} ' +
  251. ':visited, :visited * { color: #551A8B !important;} ' +
  252. 'body {position:static !important; max-width:' + winW + 'px !important;}';
  253. if(document.createStyleSheet) {
  254. document.createStyleSheet("javascript:'"+styles+"'");
  255. } else {
  256. newSS=document.createElement('link');
  257. newSS.rel='stylesheet';
  258. newSS.href='data:text/css,'+escape(styles);
  259. document.getElementsByTagName("head")[0].appendChild(newSS);
  260. }})();
  261. //$('#jcBtnPageDown').hide();
  262. $('#jcBtnPageDown').remove();
  263. }
  264. function doJcEasyView_v2() {
  265. // 易讀性 v2
  266. $('div').each(function() {
  267. if (($(this).width()<=280) && ($(this).height()<500)) {
  268. $(this).remove();
  269. }
  270. });
  271. $('body').find('script').remove();
  272. $('body').find('*')
  273. .css('width','auto')
  274. .css('clear','both')
  275. .css('float','none')
  276. .css('position' , 'static')
  277. .css('border','0px solid black')
  278. .css('background-image','none')
  279. //.css('background-color','white')
  280. //.css('color','black')
  281. .css('background-color','')
  282. .css('color','')
  283. .css('font-size', '1cm')
  284. .css('line-height','1.2cm')
  285. .css('height','auto')
  286. .css('display','block')
  287. .attr('id','');
  288. $('textarea').css('font-size', '');
  289. }
  290. });
  291. })(jQuery);