From c69f4cb8864345d756ed17b329d9b552ab5591e8 Mon Sep 17 00:00:00 2001 From: hogelog Date: Sat, 18 Apr 2009 18:11:50 +0000 Subject: * support frame page. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@32607 d0d07461-0603-4401-acd4-de1884942a52 --- marker_reader.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'marker_reader.js') diff --git a/marker_reader.js b/marker_reader.js index b560f88..7ed5ffe 100644 --- a/marker_reader.js +++ b/marker_reader.js @@ -10,7 +10,7 @@ var PLUGIN_INFO = {NAME} marker PageDown/PageUp. hogelog - 0.0.7 + 0.0.8 GPL 2.1pre 2.1pre @@ -54,6 +54,15 @@ let ignorePages = liberator.globalVariables.marker_reader_ignore || /^http:\/\/(?:reader\.livedoor|fastladder)\.com\/(?:reader|public)\//]; function near(p1, p2, e) p1-e <= p2 && p2 <= p1+e; +function focusDocument(win) { + let frames = win.frames; + if (!frames) return win.document; + for (let i=0,len=win.frames.length;i1 ? count : 1); + reader.focusNavi(focusDocument(content), count>1 ? count : 1); }, {flags: Mappings.flags.COUNT}); mappings.addUserMap([config.browserModes], [up], "marker PageUp", function (count) { - reader.focusNavi(content.document, -(count>1 ? count : 1)); + reader.focusNavi(focusDocument(content), -(count>1 ? count : 1)); }, {flags: Mappings.flags.COUNT}); } commands.addUserCommand(["markersinsert", "minsert"], "insert markers", function () { - reader.insertMarkers(content.document); + reader.insertMarkers(focusDocument(content)); }); commands.addUserCommand(["markersremove", "mremove"], "remove markers", function () { - reader.removeMarkers(content.document); + reader.removeMarkers(focusDocument(content)); }); commands.addUserCommand(["markernext", "mnext"], "marker PageDown", function () { - reader.focusNavi(content.document, 1); + reader.focusNavi(focusDocument(content, 1)); }); commands.addUserCommand(["markerprev", "mprev"], "marker PageUp", function () { - reader.focusNavi(content.document, -1); + reader.focusNavi(focusDocument(content, -1)); }); if (liberator.globalVariables.marker_reader_onload !== 0) { function autoInsert(win) { - if (win.frameElement) return; + //if (win.frameElement) return; let uri = win.location.href; if (ignorePages.some(function(r) r.test(uri))) return; let doc = win.document; @@ -231,6 +242,9 @@ if (liberator.globalVariables.marker_reader_onload !== 0) { reader.removeMarkers(doc); reader.insertMarkers(doc); + + let frames = win.frames; + for (let i=0,len=frames.length;i