亚马逊的脚本似乎无法运行

时间:2015-01-20 20:42:58

标签: javascript greasemonkey

我是JavaScript的新手,并且根据我所知的C ++代码和查看其他Greasemonkey脚本拼凑了这些内容。此脚本旨在添加链接以在ereaderiq.com上查看任何Kindle电子书。

不幸的是,它似乎没有做任何事情。我确定我错过了一些简单而基本的东西,但希望别人的眼睛能够发现我失踪的一切。这是我第一次尝试编写自己的Greasemonkey脚本。

// ==UserScript==
// @name        View Kindle Book on ereaderiq
// @namespace   buran.public
// @description Adds a link to Amazon Kindle book product pages for easy viewing of that book on ereaderiq.com
// @include     *.amazon.com/*
// @include     *.amzn.com/*
// @version     1
// @grant       none
// ==/UserScript==

function getASIN(urlstring) {
  var asinMatch;
  asinMatch = whereami.match(/\/exec\/obidos\/ASIN\/(\w{10})/i);
  if (!asinMatch) { asinMatch = urlstring.match(/\/gp\/product\/(\w{10})/i); }
  if (!asinMatch) { asinMatch = urlstring.match(/\/exec\/obidos\/tg\/detail\/\-\/(\w{10})/i); }
  if (!asinMatch) { asinMatch = urlstring.match(/\/dp\/(\w{10})/i); }
  if (!asinMatch) { return null; }
  return asinMatch[1];
}

asin = getASIN(window.location.href);
var bl = document.getElementById("btAsinTitle");

if asin.substring(0,3) !== "B00" {
  //do-nothing code
} else {
  var bookTitle = document.getElementById("btAsinTitle");
  var elmNewContent = document.createElement('a');
  elmNewContent.href = 'http://www.example.com/';

  var sb = "<a href='" + url + "'>click here</a>";

  var ereaderiqURL = "[<a href='http://www.ereaderiq.com/dp/" + asin + "'>View on eReaderIQ</a>]";

  elmNewContent.appendChild(document.createTextNode('click here'));

  var elmFoo = document.getElementById('foo');
  elmFoo.parentNode.insertBefore(elmNewContent, elmFoo);
}

0 个答案:

没有答案
相关问题