Created
March 31, 2011 15:30
-
-
Save syohex/896569 to your computer and use it in GitHub Desktop.
ページの移動
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
function dmmPage (location, pageNum) { | |
var nextLocation; | |
if (location.indexOf("page=") != -1) { | |
var page = location.match(/page=(\d+)/)[1]; | |
var nextPage = "page=" + (parseInt(page) + pageNum); | |
nextLocation = location.replace(/page=(\d+)/, nextPage); | |
} else if (location.indexOf("list") != -1){ | |
if (pageNum < 0) { | |
return false; | |
} | |
var nextPage = "page=" + (0 + parseInt(pageNum)) + "/"; | |
nextLocation = location.replace(/\/=\//, "/=/" + nextPage); | |
} else { | |
return false; | |
} | |
return nextLocation; | |
} | |
key.setViewKey('P', function (ev, arg) { | |
var currentLocation = window.content.document.location.href; | |
if (currentLocation.indexOf("www.dmm.co.jp") != -1) { | |
prevPage = dmmPage(currentLocation, -1); | |
if (prevPage !== false) { | |
window.content.document.location.href = prevPage; | |
} | |
} | |
}, '前のページに移動'); | |
key.setViewKey('N', function (ev, arg) { | |
var currentLocation = window.content.document.location.href; | |
if (currentLocation.indexOf("www.dmm.co.jp") != -1) { | |
nextPage = dmmPage(currentLocation, 1); | |
if (nextPage !== false) { | |
window.content.document.location.href = nextPage; | |
} | |
} | |
}, '次のページに移動'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment