Created
August 31, 2012 14:20
-
-
Save poochin/3553378 to your computer and use it in GitHub Desktop.
AutoPagerize の先読みをより早い段階で読み込みを行うようにさせるパッチです
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *** _autopagerize.user.js 2012-08-31 22:37:04.823104821 +0900 | |
| --- autopagerize.user.js 2012-08-31 23:16:49.413881873 +0900 | |
| *************** | |
| *** 52,57 **** | |
| --- 52,60 ---- | |
| this.pageNum = 1 | |
| this.info = info | |
| this.state = settings.disable ? 'disable' : 'enable' | |
| + this.loading = false | |
| + this.prefetch = null | |
| + this.prepage = null | |
| var self = this | |
| var url = this.getNextURL(info.nextLink, document, location.href) | |
| *************** | |
| *** 172,179 **** | |
| var scrollHeight = Math.max(document.documentElement.scrollHeight, | |
| document.body.scrollHeight) | |
| var remain = scrollHeight - window.innerHeight - window.scrollY | |
| ! if (this.state == 'enable' && remain < this.remainHeight) { | |
| ! this.request() | |
| } | |
| } | |
| --- 175,193 ---- | |
| var scrollHeight = Math.max(document.documentElement.scrollHeight, | |
| document.body.scrollHeight) | |
| var remain = scrollHeight - window.innerHeight - window.scrollY | |
| ! if (this.state == 'enable') { | |
| ! if (this.loading === false && this.prefetch === null) { | |
| ! this.request() | |
| ! } | |
| ! if (remain < this.remainHeight) { | |
| ! this.showLoading(true); | |
| ! } | |
| ! if (this.prefetch !== null && remain < this.remainHeight) { | |
| ! // this.request() | |
| ! this.hookAddPage(this.prefetch, this.prepage) | |
| ! this.showLoading(false); | |
| ! this.setLoading(false); | |
| ! } | |
| } | |
| } | |
| *************** | |
| *** 194,199 **** | |
| --- 208,225 ---- | |
| this.state = 'disable' | |
| } | |
| + AutoPager.prototype.loadingToggle = function() { | |
| + this.loading != this.loading | |
| + } | |
| + | |
| + AutoPager.prototype.setLoading = function(sw) { | |
| + this.loading = sw | |
| + } | |
| + | |
| + AutoPager.prototype.getLoading = function() { | |
| + return this.loading | |
| + } | |
| + | |
| AutoPager.prototype.request = function() { | |
| if (!this.requestURL || this.lastRequestURL == this.requestURL) { | |
| return | |
| *************** | |
| *** 209,215 **** | |
| } | |
| this.lastRequestURL = this.requestURL | |
| ! this.showLoading(true) | |
| if (Extension.isFirefox()) { | |
| extension.postMessage('get', { url: this.requestURL, fromURL: location.href, charset: document.characterSet, cookie: document.cookie }, function(res) { | |
| if (res.responseText && res.finalURL) { | |
| --- 235,242 ---- | |
| } | |
| this.lastRequestURL = this.requestURL | |
| ! // this.showLoading(true) | |
| ! this.setLoading(true) | |
| if (Extension.isFirefox()) { | |
| extension.postMessage('get', { url: this.requestURL, fromURL: location.href, charset: document.characterSet, cookie: document.cookie }, function(res) { | |
| if (res.responseText && res.finalURL) { | |
| *************** | |
| *** 273,284 **** | |
| } | |
| this.loadedURLs[this.requestURL] = true | |
| ! page = this.addPage(htmlDoc, page) | |
| ! AutoPager.filters.forEach(function(i) { | |
| ! i(page) | |
| ! }) | |
| this.requestURL = url | |
| ! this.showLoading(false) | |
| this.onScroll() | |
| if (!url) { | |
| debug('nextLink not found.', this.info.nextLink, htmlDoc) | |
| --- 300,309 ---- | |
| } | |
| this.loadedURLs[this.requestURL] = true | |
| ! this.prefetch = htmlDoc | |
| ! this.prepage = page | |
| this.requestURL = url | |
| ! // this.showLoading(false) | |
| this.onScroll() | |
| if (!url) { | |
| debug('nextLink not found.', this.info.nextLink, htmlDoc) | |
| *************** | |
| *** 287,292 **** | |
| --- 312,333 ---- | |
| var ev = document.createEvent('Event') | |
| ev.initEvent('GM_AutoPagerizeNextPageLoaded', true, false) | |
| document.dispatchEvent(ev) | |
| + | |
| + /* | |
| + page = this.addPage(htmlDoc, page) | |
| + AutoPager.filters.forEach(function(i) { | |
| + i(page) | |
| + }) | |
| + */ | |
| + } | |
| + | |
| + AutoPager.prototype.hookAddPage = function(htmlDoc, page) { | |
| + page = this.addPage(htmlDoc, page) | |
| + AutoPager.filters.forEach(function(i) { | |
| + i(page) | |
| + }) | |
| + this.prefetch = null | |
| + this.prepage = null | |
| } | |
| AutoPager.prototype.addPage = function(htmlDoc, page) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment