如何使用户脚本浏览页面?

时间:2018-04-04 01:29:05

标签: javascript navigationbar next

我猜这两个链接可供我参考:

how to get the arrow keys on the keyboard to trigger navigation (previous/next page) links within a blog

How do I click on this button with Greasemonkey?

这是页面上的元素:

<div class="corner-nav-bg">
<div class="sel-prev"><span class="left-arrow"></span>"Previous"</div>
<div class="sel-next enabled">"Next"<span class="right-arrow"></span></div>
</div>

当从一个页面转到下一个页面时,URL不会更改。

这是我能为按钮找到的javascript。

nextItem: function()
{
  var group = this.groups[ this.currentGroup ];
  if (this.currentItem < group.items.length - 1)
    this.loadItem( this.currentItem + 1 );
},

// update navigation controls
      $(".item").removeClass("selected");
      itemElem.addClass("selected");
      var allIndex = group.items[ n ].index;
      ChemShared.addRemoveClass( $(".sel-prev"), "enabled", n > 0 );
      ChemShared.addRemoveClass( $(".sel-next"), "enabled", 
      n < group.items.length-1 );

 // activate navigation
  $(".sel-item").click(function(){
    if (! self.unsubmittedWarning())
      return;
    var n = parseInt( $(this).attr("rel") );
    self.loadItem( n );
  });
  $(".sel-prev").click(function(){
    if (! self.unsubmittedWarning())
      return;
    self.prevItem();
  });
  $(".sel-next").click(function(){
    if (! self.unsubmittedWarning())
      return;
    self.nextItem();
  });

 // set whether item has answer entered
  var navigatorItem = $(".item.selected");
  if (isAnswerEntered)
    ChemShared.addRemoveClass( navigatorItem, "answer-entered", true );
  else 
    ChemShared.addRemoveClass( navigatorItem, "answer-entered", false );
},
prevItem: function()
{
  if (this.currentItem > 0)
    this.loadItem( this.currentItem - 1 );
},
nextItem: function()
{
  var group = this.groups[ this.currentGroup ];
  if (this.currentItem < group.items.length - 1)
    this.loadItem( this.currentItem + 1 );
},

0 个答案:

没有答案