Greasy Fork is available in English.

eBay on Google Maps

Show eBay items on a Google Map. Links from search results and individual items.

  1. // AuctionSearchKit - "eBay on Google Maps" User Script
  2. // Version 8.5
  3. // 2012-03-08
  4. // Copyright (c) 2008, Auction Search Kit. All rights reserved.
  5. // Feedback to auctionsearchkit@gmail.com is welcome.
  6. //
  7. // --------------------------------------------------------------------
  8. //
  9. // This is a Greasemonkey user script.
  10. //
  11. // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
  12. // Then restart Firefox and revisit this script.
  13. // Under Tools, there will be a new menu item to "Install User Script".
  14. // Accept the default configuration and install.
  15. //
  16. // To uninstall, go to Tools/Manage User Scripts,
  17. // select "eBay on Google Maps", and click Uninstall.
  18. //
  19. // --------------------------------------------------------------------
  20. //
  21. // ==UserScript==
  22. // @name eBay on Google Maps
  23. // @namespace http://www.auctionsearchkit.co.uk
  24. // @description Show eBay items on a Google Map. Links from search results and individual items.
  25. // @include http://*.ebay.*
  26. // @include https://*.ebay.*
  27. // @version 8.5
  28. // ==/UserScript==
  29.  
  30. // Script version. NOTE: This should also be updated at the top.
  31. var version = '8.5';
  32. var DEBUG_MODE = false;
  33.  
  34. // If in DEBUG mode and FireBug is installed, define a logging function using the FireBug console
  35. if ((DEBUG_MODE === true) && (unsafeWindow.console)) {
  36. // Log a variable's value via the Firebug console (if debug mode is turned on)
  37. function fbLog(name, value) {
  38. if (DEBUG_MODE === true) {
  39. switch (typeof value) {
  40. case 'undefined':
  41. unsafeWindow.console.log(name + ' is undefined');
  42. break;
  43. case 'object':
  44. if (value === null) {
  45. unsafeWindow.console.log(name + ' is null');
  46. } else {
  47. if (value.constructor === Date) {
  48. unsafeWindow.console.log(name + ' = ' + value);
  49. } else if (typeof value.length == 'undefined') {
  50. unsafeWindow.console.log(name + ':');
  51. } else if (value.length === 0) {
  52. unsafeWindow.console.log(name + ' is empty (length = 0)');
  53. } else {
  54. unsafeWindow.console.log(name + ' (length = ' + value.length + '):');
  55. }
  56. unsafeWindow.console.dir(value);
  57. }
  58. break;
  59. case 'string':
  60. unsafeWindow.console.log(name + ' = "' + value + '"');
  61. break;
  62. default:
  63. unsafeWindow.console.log(name + ' = ' + value);
  64. break;
  65. }
  66. }
  67. }
  68. } else {
  69. // Assign a function that does nothing whenever a logging call is made
  70. function fbLog(name, value) {}
  71. }
  72.  
  73. try {
  74. // Get all the elements below the specified node with the specified ID, name, class, tag and any further checks
  75. // (all parameters are optional)
  76. function getElementsByINCT(node, elementId, elementName, className, tagName, furtherNodeChecksJs) {
  77. var elementsArray = [];
  78. try {
  79. var logText = 'Elements for ID=' + elementId
  80. + ', name=' + elementName
  81. + ', class=' + className
  82. + ', tag=' + tagName
  83. + ', js=' + (typeof furtherNodeChecksJs == 'undefined' ? '<undefined>' : '"' + furtherNodeChecksJs + '"');
  84. if ((typeof elementId == 'undefined') || (elementId === '')) {
  85. elementId = null;
  86. }
  87. if ((typeof elementName == 'undefined') || (elementName === '')) {
  88. elementName = null;
  89. }
  90. if ((typeof className == 'undefined') || (className === '')) {
  91. className = null;
  92. }
  93. if ((typeof tagName == 'undefined') || (tagName === null) || (tagName === '')) {
  94. tagName = null;
  95. }
  96. if ((typeof node == 'undefined') || (node === null) || (node === '')) {
  97. node = document;
  98. }
  99. if ((typeof furtherNodeChecksJs == 'undefined') || (furtherNodeChecksJs === '')) {
  100. furtherNodeChecksJs = null;
  101. }
  102. var elementsNodeList = [];
  103. if ((elementName !== null) && (typeof node.getElementsByName == 'function')) {
  104. var elementsNodeList = node.getElementsByName(elementName);
  105. elementName = null;
  106. } else if ((className !== null) && (typeof node.getElementsByClassName == 'function')) {
  107. var elementsNodeList = node.getElementsByClassName(className);
  108. className = null;
  109. } else if ((tagName !== null) && (typeof node.getElementsByTagName == 'function')) {
  110. var elementsNodeList = node.getElementsByTagName(tagName);
  111. tagName = null;
  112. } else if ((typeof node.elements == 'object') && (node.elements !== null)) {
  113. var elementsNodeList = node.elements;
  114. } else if ((typeof node.all == 'object') && (node.all !== null)) {
  115. var elementsNodeList = node.all;
  116. }
  117. var nodeChecksJs = '';
  118. if (elementId !== null) {
  119. nodeChecksJs += '(/^' + elementId + '$/i.test(node.id) == true) && '
  120. }
  121. if (elementName !== null) {
  122. nodeChecksJs += '(/^' + elementName + '$/i.test(node.name) == true) && '
  123. }
  124. if (className !== null) {
  125. nodeChecksJs += '(/^' + className + '$/i.test(node.className) == true) && '
  126. }
  127. if (tagName !== null) {
  128. nodeChecksJs += '(/^' + tagName + '$/i.test(node.tagName) == true) && '
  129. }
  130. if (furtherNodeChecksJs !== null) {
  131. nodeChecksJs += '(' + furtherNodeChecksJs + ') && '
  132. }
  133. if (nodeChecksJs === '') {
  134. nodeChecksJs = 'true';
  135. } else {
  136. nodeChecksJs = nodeChecksJs.substring(0, nodeChecksJs.length - 4);
  137. }
  138. for (var enlIndex = 0; enlIndex < elementsNodeList.length; enlIndex++) {
  139. node = elementsNodeList[enlIndex];
  140. if (eval(nodeChecksJs) === true) {
  141. elementsArray.push(node);
  142. }
  143. }
  144. fbLog(logText, elementsArray);
  145. } catch (err) {
  146. fbLog('Unexpected error', err);
  147. }
  148.  
  149. return elementsArray;
  150. }
  151.  
  152. function getItemsUrl(rootElement) {
  153. if (typeof rootElement == 'undefined') {
  154. rootElement = document;
  155. }
  156. var url = null;
  157. var anchorElementsArray = rootElement.getElementsByTagName('a');
  158. if (anchorElementsArray !== null) {
  159. var regexp = /(&|\?|QQ|%26|Q26|_W0QQ)item(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i;
  160. var itemsArray = [];
  161. for (var index = 0; index < anchorElementsArray.length; index++) {
  162. var anchorElement = anchorElementsArray[index];
  163. var href = anchorElement.href;
  164. var matches = regexp.exec(href);
  165. if (matches != null) {
  166. itemsArray.push(matches[3]);
  167. }
  168. }
  169. if (itemsArray.length > 0) {
  170. itemsArray.sort();
  171. url = 'http://www.auctionsearchkit.co.uk/search.php?item=';
  172. var prevItem = null;
  173. for (var index = 0; index < itemsArray.length; index++) {
  174. var item = itemsArray[index];
  175. if (item !== prevItem) {
  176. url += item + ',';
  177. prevItem = item;
  178. }
  179. }
  180. url = url.substring(0, url.length - 1);
  181. }
  182. }
  183. return url;
  184. }
  185.  
  186. // Get the item ID from the current URL if possible
  187. function getItemIdFromUrl(url) {
  188. // If a URL is not supplied, use the current page URL
  189. if (typeof url == 'undefined') {
  190. url = document.location.href;
  191. }
  192. var matches = /(&|\?|QQ|%26|Q26|_W0QQ)item(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i.exec(url);
  193. if (matches == null) {
  194. var itemId = null;
  195. } else {
  196. var itemId = matches[3];
  197. }
  198. if (itemId == null) {
  199. var matches = /\/([0-9]{9,12})(\?|_W0QQ|$)/i.exec(url);
  200. if (matches == null) {
  201. var itemId = null;
  202. } else {
  203. var itemId = matches[1];
  204. }
  205. }
  206. return itemId;
  207. }
  208.  
  209. var advsearchElement = document.getElementById('AdvSearchId');
  210. var headerSearchFormElements = document.getElementsByName('headerSearch');
  211. if ((headerSearchFormElements != null) &&
  212. (headerSearchFormElements[0] != null) &&
  213. (advsearchElement != null)) {
  214. newElement = document.createElement('span');
  215. newElement.innerHTML = ' <input class="gh-btn"'
  216. + ' title="Show the results of this search on a Google Map"'
  217. + ' type="button" value="Map-Search"'
  218. + ' onclick="var headerSearchFormElements = document.getElementsByName(\'headerSearch\');'
  219. + ' if ((headerSearchFormElements != null) && (headerSearchFormElements[0] != null)) {'
  220. + ' var url = headerSearchFormElements[0].action;'
  221. + ' if ((url == \'\') || (url[0] == \'?\') || (url[0] == \'/\')) {'
  222. + ' url = window.location.href + url; '
  223. + ' }'
  224. + ' var allCtrls = headerSearchFormElements[0].elements;'
  225. + ' for (ctrlNum = 0; ctrlNum < allCtrls.length; ctrlNum++) {'
  226. + ' var ctrl = allCtrls[ctrlNum];'
  227. + ' var ctrlType = ctrl.type;'
  228. + ' if (typeof ctrlType != \'undefined\') {'
  229. + ' ctrlType = ctrlType.toLowerCase();'
  230. + ' if ((ctrlType != \'submit\') && (ctrlType != \'reset\') &&'
  231. + ' (ctrlType != \'image\') && (ctrlType != \'button\') &&'
  232. + ' (((ctrlType != \'checkbox\') && (ctrlType != \'radio\')) || (ctrl.checked != false))) {'
  233. + ' url += (url.indexOf(\'?\') >= 0) ? \'&\' : \'?\';'
  234. + ' url += ctrl.name + \'=\' + escape(ctrl.value);'
  235. + ' }'
  236. + ' }'
  237. + ' }'
  238. + ' window.open(\'http://www.auctionsearchkit.co.uk/search.php?\''
  239. + ' + url + \'&asksrc=gm' + version + 'p1\'); }">';
  240. advsearchElement.parentNode.insertBefore(newElement, advsearchElement);
  241. }
  242.  
  243. var submitElementsArray = getElementsByINCT(null, null, null, 'standard', 'input');
  244. if (submitElementsArray.length <= 0) {
  245. var searchButtonElement = document.getElementById('inlinebutton');
  246. var advSearchFormElements = document.getElementsByName('advsearch_form');
  247. if ((advSearchFormElements != null) &&
  248. (advSearchFormElements[0] != null) &&
  249. (searchButtonElement != null)) {
  250. var newElement = document.createElement('td');
  251. newElement.innerHTML = ' <input title="Show the results of this search on a Google Map"'
  252. + ' type="button" class="standard" value="Map-Search"'
  253. + ' onclick="var advSearchFormElements = document.getElementsByName(\'advsearch_form\');'
  254. + ' if ((advSearchFormElements != null) && (advSearchFormElements[0] != null)) {'
  255. + ' var url = advSearchFormElements[0].action;'
  256. + ' if ((url == \'\') || (url[0] == \'?\') || (url[0] == \'/\')) {'
  257. + ' url = window.location.href + url; '
  258. + ' }'
  259. + ' var allCtrls = advSearchFormElements[0].elements;'
  260. + ' for (ctrlNum = 0; ctrlNum < allCtrls.length; ctrlNum++) {'
  261. + ' var ctrl = allCtrls[ctrlNum];'
  262. + ' var ctrlType = ctrl.type;'
  263. + ' if (typeof ctrlType != \'undefined\') {'
  264. + ' ctrlType = ctrlType.toLowerCase();'
  265. + ' if ((ctrlType != \'submit\') && (ctrlType != \'reset\') &&'
  266. + ' (ctrlType != \'image\') && (ctrlType != \'button\') &&'
  267. + ' (((ctrlType != \'checkbox\') && (ctrlType != \'radio\')) || (ctrl.checked != false))) {'
  268. + ' url += (url.indexOf(\'?\') >= 0) ? \'&\' : \'?\';'
  269. + ' url += ctrl.name + \'=\' + escape(ctrl.value);'
  270. + ' }'
  271. + ' }'
  272. + ' }'
  273. + ' window.open(\'http://www.auctionsearchkit.co.uk/search.php?\''
  274. + ' + url + \'&asksrc=gm' + version + 'p2\'); }">';
  275. searchButtonElement.parentNode.insertBefore(newElement, searchButtonElement.nextSibling);
  276. newElement = document.createElement('td');
  277. newElement.innerHTML = '<img width="10" height="1" border="0" '
  278. + 'xmlns="http://www.w3.org/1999/xhtml" src="http://pics.ebaystatic.com/aw/pics/s.gif"/>'
  279. searchButtonElement.parentNode.insertBefore(newElement, searchButtonElement.nextSibling);
  280. }
  281. } else {
  282. for (submitElementIndex = 0; submitElementIndex < submitElementsArray.length; submitElementIndex++) {
  283. var newElement = document.createElement('span');
  284. newElement.innerHTML = '<input title="Show the results of this search on a Google Map"'
  285. + ' type="button" value="Map-Search" class="standard"'
  286. + ' onclick="var advSearchFormElements = document.getElementsByName(\'advsearch_form\');'
  287. + ' if ((advSearchFormElements != null) && (advSearchFormElements[0] != null)) {'
  288. + ' var url = advSearchFormElements[0].action;'
  289. + ' if ((url == \'\') || (url[0] == \'?\') || (url[0] == \'/\')) {'
  290. + ' url = window.location.href + url; '
  291. + ' }'
  292. + ' var allCtrls = advSearchFormElements[0].elements;'
  293. + ' for (ctrlNum = 0; ctrlNum < allCtrls.length; ctrlNum++) {'
  294. + ' var ctrl = allCtrls[ctrlNum];'
  295. + ' var ctrlType = ctrl.type;'
  296. + ' if (typeof ctrlType != \'undefined\') {'
  297. + ' ctrlType = ctrlType.toLowerCase();'
  298. + ' if ((ctrlType != \'submit\') && (ctrlType != \'reset\') &&'
  299. + ' (ctrlType != \'image\') && (ctrlType != \'button\') &&'
  300. + ' (((ctrlType != \'checkbox\') && (ctrlType != \'radio\')) || (ctrl.checked != false))) {'
  301. + ' url += (url.indexOf(\'?\') >= 0) ? \'&\' : \'?\';'
  302. + ' url += ctrl.name + \'=\' + escape(ctrl.value);'
  303. + ' }'
  304. + ' }'
  305. + ' }'
  306. + ' window.open(\'http://www.auctionsearchkit.co.uk/search.php?\''
  307. + ' + url + \'&asksrc=gm' + version + 'p2b\'); }">';
  308. submitElementsArray[submitElementIndex].parentNode.insertBefore(
  309. newElement,
  310. submitElementsArray[submitElementIndex].nextSibling);
  311. }
  312. }
  313.  
  314. var saveSearchElement = document.getElementById('span_save_search');
  315. if (saveSearchElement == null) {
  316. saveSearchElement = document.getElementById('fpcSaveSearchLink');
  317. }
  318. if (saveSearchElement == null) {
  319. saveSearchElement = document.getElementById('saveSearchLinkDash');
  320. }
  321. if (saveSearchElement == null) {
  322. var saveSearchElementsArray = getElementsByINCT(null, null, null, 'saveSearch', 'span');
  323. if (saveSearchElementsArray.length > 0) {
  324. saveSearchElement = saveSearchElementsArray[0];
  325. }
  326. }
  327. if (saveSearchElement != null) {
  328. var newElement = document.createElement('span');
  329. newElement.innerHTML = '<span class="saveSearch"> <a class="links" title="Show the results of this search on a Google Map" '
  330. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  331. + window.location.href + '&asksrc=gm' + version + 'p3" target="_blank">Map this search</a> | </span>';
  332. saveSearchElement.parentNode.insertBefore(newElement, saveSearchElement);
  333.  
  334. var url = getItemsUrl();
  335. if (url != null) {
  336. newElement = document.createElement('span');
  337. newElement.innerHTML = '<span class="saveSearch"> <a title="Show all the items on the current page on a Google Map" '
  338. + ' href="' + url + '&asksrc=gm' + version + 'p4" target="_blank">Map all items on page</a> |</span>';
  339. saveSearchElement.parentNode.insertBefore(newElement, saveSearchElement);
  340. }
  341. }
  342.  
  343. var watchingElement = document.getElementById('watching');
  344. if (watchingElement != null) {
  345. var newElement = document.createElement('td');
  346. newElement.align = 'right';
  347. newElement.innerHTML = '<b><a title="Show this item\'s location on a Google Map"'
  348. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  349. + window.location.href
  350. + '&asksrc=gm' + version + 'p5" target="_blank">Map&nbsp;this&nbsp;item</a></b>';
  351. watchingElement.parentNode.insertBefore(newElement, watchingElement);
  352. }
  353.  
  354. var bsElement = document.getElementById('bs');
  355. var findElement = document.getElementById('find');
  356. if ((bsElement != null) &&
  357. (findElement != null)) {
  358. newElement = document.createElement('span');
  359. newElement.innerHTML = ' <input title="Show the results of this search on a Google Map"'
  360. + ' type="button" class="standard" value="Map-Search"'
  361. + ' onclick="var findElement = document.getElementById(\'find\');'
  362. + ' if (findElement != null) {'
  363. + ' var qMarkPos = window.location.href.search(/(\\?|__W0QQ)/i);'
  364. + ' if (qMarkPos > 0) {'
  365. + ' var url = window.location.href.substring(0, qMarkPos);'
  366. + ' } else { '
  367. + ' var url = \'\';'
  368. + ' }'
  369. + ' var allCtrls = findElement.elements;'
  370. + ' for (ctrlNum = 0; ctrlNum < allCtrls.length; ctrlNum++) {'
  371. + ' var ctrl = allCtrls[ctrlNum];'
  372. + ' var ctrlType = ctrl.type;'
  373. + ' if (typeof ctrlType != \'undefined\') {'
  374. + ' ctrlType = ctrlType.toLowerCase();'
  375. + ' if ((ctrlType != \'submit\') && (ctrlType != \'reset\') &&'
  376. + ' (ctrlType != \'image\') && (ctrlType != \'button\') &&'
  377. + ' (((ctrlType != \'checkbox\') && (ctrlType != \'radio\')) || (ctrl.checked != false))) {'
  378. + ' url += (url.indexOf(\'?\') >= 0) ? \'&\' : \'?\';'
  379. + ' url += ctrl.name + \'=\' + escape(ctrl.value);'
  380. + ' }'
  381. + ' }'
  382. + ' }'
  383. + ' window.open(\'http://www.auctionsearchkit.co.uk/search.php?\''
  384. + ' + url + \'&asksrc=gm' + version + 'p6\'); }">';
  385. bsElement.parentNode.insertBefore(newElement, bsElement.nextSibling);
  386. }
  387.  
  388. var watchButtonElement = document.getElementById('watchLinkMiddle');
  389. if (watchButtonElement != null) {
  390. var newElement = document.createElement('span');
  391. newElement.innerHTML = ' <input class="navigation" title="Show the results of this search on a Google Map"'
  392. + ' type="button" class="standard" value="Map This Item"'
  393. + ' onclick="window.open(\'http://www.auctionsearchkit.co.uk/search.php?'
  394. + window.location.href + '&asksrc=gm' + version + 'p7\');"';
  395. watchButtonElement.parentNode.insertBefore(newElement, watchButtonElement);
  396. }
  397.  
  398. if (window.location.href.search(/my\.ebay/i) >= 0) {
  399. var titleElementsArray = getElementsByINCT(null, null, null, 'c_Title', 'td');
  400. for (var index = 0; index < titleElementsArray.length; index++) {
  401. var titleElement = titleElementsArray[index];
  402. var anchorElementsArray = titleElement.getElementsByTagName('a');
  403. if (anchorElementsArray.length == 1) {
  404. var anchorElement = anchorElementsArray[0];
  405. var newElement = document.createElement('span');
  406. newElement.innerHTML = '&nbsp;&nbsp;[<a title="Show this item on a Google Map" '
  407. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  408. + anchorElement.href
  409. + '&asksrc=gm' + version + 'p10" target="_blank">Map&nbsp;Item</a>] ';
  410. anchorElement.parentNode.insertBefore(newElement, anchorElement.nextSibling);
  411. }
  412. }
  413.  
  414. var searchElementsArray = getElementsByINCT(null, null, null, 'c_SearchName', 'td');
  415. for (var index = 0; index < searchElementsArray.length; index++) {
  416. var titleElement = searchElementsArray[index];
  417. var anchorElementsArray = titleElement.getElementsByTagName('a');
  418. if (anchorElementsArray.length == 1) {
  419. var anchorElement = anchorElementsArray[0];
  420. var newElement = document.createElement('span');
  421. newElement.innerHTML = '&nbsp;&nbsp;[<a title="Show this item on a Google Map" '
  422. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  423. + anchorElement.href
  424. + '&asksrc=gm' + version + 'p11" target="_blank">Map&nbsp;Search</a>] ';
  425. anchorElement.parentNode.insertBefore(newElement, anchorElement.nextSibling);
  426. }
  427. }
  428.  
  429. var pdmColElementsArray = getElementsByINCT(null, null, null, 'pdm-col', 'ul');
  430. for (var index = 0; index < pdmColElementsArray.length; index++) {
  431. var pdmColElement = pdmColElementsArray[index];
  432. var pdmItemElementsArray = getElementsByINCT(pdmColElement, null, null, 'pdm-item', 'li');
  433. var pdmItemElement = pdmItemElementsArray[0];
  434. var anchorElementsArray = pdmItemElement.getElementsByTagName('a');
  435. if (anchorElementsArray.length == 1) {
  436. var anchorElement = anchorElementsArray[0];
  437. if ((anchorElement.innerHTML != 'Summary') &&
  438. (anchorElement.innerHTML != 'Inbox') &&
  439. (anchorElement.innerHTML.substring(0, 18) != '<span id="editmenu') &&
  440. (anchorElement.innerHTML.substring(0, 17) != '<span id="imgspan') &&
  441. (anchorElement.innerHTML.substring(0, 3) != 'All') &&
  442. (anchorElement.innerHTML.substring(0, 4) != 'Last') &&
  443. (anchorElement.innerHTML.substring(0, 4) != 'Time')) {
  444. var newElement = document.createElement('li');
  445. newElement.className = 'pdm-item';
  446. if (anchorElement.innerHTML == 'Go to search results') {
  447. newElement.innerHTML = '<a title="Show this search on a Google Map" '
  448. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  449. + anchorElement.href
  450. + '&asksrc=gm' + version + 'p12b" target="_blank">Map&nbsp;this&nbsp;search</a>';
  451. } else {
  452. newElement.innerHTML = '<a title="Show this item on a Google Map" '
  453. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  454. + anchorElement.href
  455. + '&asksrc=gm' + version + 'p12" target="_blank">Map&nbsp;this&nbsp;item</a>';
  456. }
  457. pdmItemElement.parentNode.insertBefore(newElement, pdmItemElement.nextSibling);
  458. }
  459. }
  460. }
  461.  
  462. var titleElementsArray = getElementsByINCT(null, 'ttl_.*', null, null, 'a');
  463. for (var index = 0; index < titleElementsArray.length; index++) {
  464. var titleElement = titleElementsArray[index];
  465. var newElement = document.createElement('span');
  466. newElement.innerHTML = '&nbsp;&nbsp;[<a title="Show this item on a Google Map" '
  467. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  468. + titleElement.href
  469. + '&asksrc=gm' + version + 'p13" target="_blank">Map&nbsp;Item</a>] ';
  470. titleElement.parentNode.insertBefore(newElement, titleElement.nextSibling);
  471. }
  472.  
  473. var gotoSearchesElement = document.getElementById('GotoSearchesLnk');
  474. if (gotoSearchesElement != null) {
  475. var newElement = document.createElement('span');
  476. newElement.innerHTML = '<span><a id="mapsavedsearch" class="customization_paddingleft5px" title="Show the results of this search on a Google Map"'
  477. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  478. + gotoSearchesElement.href + '&asksrc=gm' + version + 'p13b" onmouseover="var gotoSearchesElement = document.getElementById(\'GotoSearchesLnk\'); if (gotoSearchesElement != null) { this.href = \'http://www.auctionsearchkit.co.uk/search.php?\' + gotoSearchesElement.href + \'&asksrc=gm' + version + 'p13b\'; }" target="_blank">Map this search</a> |</span>';
  479. gotoSearchesElement.parentNode.insertBefore(newElement, gotoSearchesElement);
  480. }
  481. }
  482.  
  483. var sacatElement = document.getElementById('_sacat');
  484. var findingSearchBarFormElement = document.getElementById('findingsearchbarfrm');
  485. if ((findingSearchBarFormElement != null) && (sacatElement != null)) {
  486. var newElement = document.createElement('span');
  487. newElement.innerHTML = ' <input title="Show the results of this search on a Google Map"'
  488. + ' type="button" value="Map-Search"'
  489. + ' onclick="var findingSearchBarFormElement = document.getElementById(\'findingsearchbarfrm\');'
  490. + ' if (findingSearchBarFormElement != null) {'
  491. + ' var url = findingSearchBarFormElement.action;'
  492. + ' if ((url == \'\') || (url[0] == \'?\') || (url[0] == \'/\')) {'
  493. + ' url = window.location.href + url; '
  494. + ' }'
  495. + ' var allCtrls = findingSearchBarFormElement.elements;'
  496. + ' for (ctrlNum = 0; ctrlNum < allCtrls.length; ctrlNum++) {'
  497. + ' var ctrl = allCtrls[ctrlNum];'
  498. + ' var ctrlType = ctrl.type;'
  499. + ' if (typeof ctrlType != \'undefined\') {'
  500. + ' ctrlType = ctrlType.toLowerCase();'
  501. + ' if ((ctrlType != \'submit\') && (ctrlType != \'reset\') &&'
  502. + ' (ctrlType != \'image\') && (ctrlType != \'button\') &&'
  503. + ' (((ctrlType != \'checkbox\') && (ctrlType != \'radio\')) || (ctrl.checked != false))) {'
  504. + ' url += (url.indexOf(\'?\') >= 0) ? \'&\' : \'?\';'
  505. + ' url += ctrl.name + \'=\' + escape(ctrl.value);'
  506. + ' }'
  507. + ' }'
  508. + ' }'
  509. + ' window.open(\'http://www.auctionsearchkit.co.uk/search.php?\''
  510. + ' + url + \'&asksrc=gm' + version + 'p14\'); }"';
  511. sacatElement.parentNode.insertBefore(newElement, sacatElement.nextSibling ? sacatElement.nextSibling.nextSibling : sacatElement.nextSibling);
  512. }
  513.  
  514. var deleteBtnElementArray = getElementsByINCT(null, null, 'SubmitAction.BulkDelete', null, 'input');
  515. if (deleteBtnElementArray.length > 0) {
  516. btnHtml = ' <input title="Display these items on a Google Map"'
  517. + ' type="button" value="Map Items"'
  518. + ' onclick="var containerElement = this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;'
  519. + ' if (containerElement != null) {'
  520. + ' var anchorElementsArray = containerElement.getElementsByTagName(\'a\');'
  521. + ' if (anchorElementsArray !== null) {'
  522. + ' var regexp = new RegExp(\'(&|\\\\?|QQ|%26|Q26|_W0QQ)item(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*\', \'i\');'
  523. + ' var itemsArray = [];'
  524. + ' for (var index = 0; index < anchorElementsArray.length; index++) {'
  525. + ' var anchorElement = anchorElementsArray[index];'
  526. + ' var href = anchorElement.href;'
  527. + ' var matches = regexp.exec(href);'
  528. + ' if (matches != null) { '
  529. + ' itemsArray.push(matches[3]);'
  530. + ' }'
  531. + ' }'
  532. + ' if (itemsArray.length > 0) {'
  533. + ' itemsArray.sort();'
  534. + ' url = \'http://www.auctionsearchkit.co.uk/search.php?item=\';'
  535. + ' var prevItem = null;'
  536. + ' for (var index = 0; index < itemsArray.length; index++) {'
  537. + ' var item = itemsArray[index];'
  538. + ' if (item !== prevItem) {'
  539. + ' url += item + \',\';'
  540. + ' prevItem = item;'
  541. + ' }'
  542. + ' }'
  543. + ' url = url.substring(0, url.length - 1);'
  544. + ' window.open(url + \'&asksrc=gm' + version + 'p15\');'
  545. + '}'
  546. + ' }'
  547. + ' }">';
  548. for (var index = 0; index < deleteBtnElementArray.length; index++) {
  549. var newElement = document.createElement('span');
  550. newElement.innerHTML = btnHtml;
  551. var deleteBtnElement = deleteBtnElementArray[index];
  552. deleteBtnElement.parentNode.insertBefore(newElement, deleteBtnElement.nextSibling);
  553. }
  554. }
  555.  
  556. var removeBtnElementArray = getElementsByINCT(null, null, 'SubmitAction.BulkRemove', null, 'input');
  557. if (removeBtnElementArray.length > 0) {
  558. btnHtml = ' <input title="Display these items on a Google Map"'
  559. + ' type="button" value="Map Items"'
  560. + ' onclick="var containerElement = this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;'
  561. + ' if (containerElement != null) {'
  562. + ' var anchorElementsArray = containerElement.getElementsByTagName(\'a\');'
  563. + ' if (anchorElementsArray !== null) {'
  564. + ' var regexp = new RegExp(\'(&|\\\\?|QQ|%26|Q26|_W0QQ)item(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*\', \'i\');'
  565. + ' var itemsArray = [];'
  566. + ' for (var index = 0; index < anchorElementsArray.length; index++) {'
  567. + ' var anchorElement = anchorElementsArray[index];'
  568. + ' var href = anchorElement.href;'
  569. + ' var matches = regexp.exec(href);'
  570. + ' if (matches != null) { '
  571. + ' itemsArray.push(matches[3]);'
  572. + ' }'
  573. + ' }'
  574. + ' if (itemsArray.length > 0) {'
  575. + ' itemsArray.sort();'
  576. + ' url = \'http://www.auctionsearchkit.co.uk/search.php?item=\';'
  577. + ' var prevItem = null;'
  578. + ' for (var index = 0; index < itemsArray.length; index++) {'
  579. + ' var item = itemsArray[index];'
  580. + ' if (item !== prevItem) {'
  581. + ' url += item + \',\';'
  582. + ' prevItem = item;'
  583. + ' }'
  584. + ' }'
  585. + ' url = url.substring(0, url.length - 1);'
  586. + ' window.open(url + \'&asksrc=gm' + version + 'p16\');'
  587. + '}'
  588. + ' }'
  589. + ' }">';
  590. for (var index = 0; index < removeBtnElementArray.length; index++) {
  591. var newElement = document.createElement('span');
  592. newElement.innerHTML = btnHtml;
  593. var removeBtnElement = removeBtnElementArray[index];
  594. removeBtnElement.parentNode.insertBefore(newElement, removeBtnElement.nextSibling);
  595. }
  596. }
  597.  
  598. var viewItemElementsArray = getElementsByINCT(null, 'viewItemId', null, null, 'td');
  599. for (var index = 0; index < viewItemElementsArray.length; index++) {
  600. var viewItemElement = viewItemElementsArray[index];
  601. var anchorElementsArray = viewItemElement.getElementsByTagName('a');
  602. if (anchorElementsArray.length == 1) {
  603. var anchorElement = anchorElementsArray[0];
  604. var newElement = document.createElement('span');
  605. newElement.innerHTML = '&nbsp;&nbsp;[<a title="Show this item on a Google Map" '
  606. + ' href="http://www.auctionsearchkit.co.uk/search.php?'
  607. + anchorElement.href
  608. + '&asksrc=gm' + version + 'p17" target="_blank">Map&nbsp;Item</a>] ';
  609. anchorElement.parentNode.insertBefore(newElement, anchorElement.nextSibling);
  610. }
  611. }
  612.  
  613. if (window.location.href.search(/feedback\.ebay/i) >= 0) {
  614. var url = getItemsUrl();
  615. if (url != null) {
  616. var menuLinksElementsArray = getElementsByINCT(null, null, null, 'menuLayerLinksYukon', 'a');
  617. if (menuLinksElementsArray.length > 0) {
  618. var menuLinksElement = menuLinksElementsArray[0];
  619. var newElement = document.createElement('span');
  620. newElement.innerHTML = '<a class="menuLayerLinksYukon" title="Show all the items on the current page on a Google Map" '
  621. + ' href="' + url + '&asksrc=gm' + version + 'p18" target="_blank">Map all items on page</a></div></span>';
  622. menuLinksElement.parentNode.insertBefore(newElement, menuLinksElement);
  623. }
  624.  
  625. var doNextListElementsArray = getElementsByINCT(null, null, null, 'outline_list dft_blt bullets', 'ul');
  626. for (dnleIndex = 0; dnleIndex < doNextListElementsArray.length; dnleIndex++) {
  627. var doNextListElement = doNextListElementsArray[dnleIndex];
  628. if (doNextListElement.childNodes.length > 0) {
  629. var newElement = document.createElement('li');
  630. newElement.class = 'bullets normal';
  631. newElement.innerHTML = '<span class="listext"><div class="ddl2-content">'
  632. + '<a title="Show all the items on the current page on a Google Map" '
  633. + ' href="' + url + '&asksrc=gm' + version + 'p19" target="_blank">Map all items on page</a></div></span>';
  634. doNextListElement.insertBefore(newElement, doNextListElement.childNodes[0]);
  635. }
  636. }
  637. }
  638. }
  639.  
  640. var watchItemElementsArray = getElementsByINCT(null, 'l_WatchItem', null, null, 'a');
  641. if (watchItemElementsArray.length > 0) {
  642. var regexp = /(&|\?|QQ|%26|Q26|_W0QQ)item(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i;
  643.  
  644. for (var index = 0; index < watchItemElementsArray.length; index++) {
  645. var watchItemElement = watchItemElementsArray[index];
  646. var href = watchItemElement.href;
  647. var matches = regexp.exec(href);
  648. if (matches != null) {
  649. var newElement = document.createElement('li');
  650. newElement.innerHTML = '<a title="Show this item on a Google Map" '
  651. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  652. + matches[3]
  653. + '&asksrc=gm' + version + 'p20" target="_blank">Map this item</a>';
  654. watchItemElement.parentNode.parentNode.insertBefore(newElement, watchItemElement.parentNode);
  655. }
  656. }
  657. } else {
  658. var viewItemElementsArray = getElementsByINCT(null, 'l_ViewItem', null, null, 'a');
  659. if (viewItemElementsArray.length > 0) {
  660. var regexp = /(&|\?|QQ|%26|Q26|_W0QQ)item(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i;
  661.  
  662. for (var index = 0; index < viewItemElementsArray.length; index++) {
  663. var viewItemElement = viewItemElementsArray[index];
  664. var href = viewItemElement.href;
  665. var matches = regexp.exec(href);
  666. if (matches != null) {
  667. var newElement = document.createElement('li');
  668. newElement.innerHTML = '<a title="Show this item on a Google Map" '
  669. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  670. + matches[3]
  671. + '&asksrc=gm' + version + 'p20" target="_blank">Map this item</a>';
  672. viewItemElement.parentNode.parentNode.insertBefore(newElement, viewItemElement.parentNode);
  673. }
  674. }
  675. }
  676. }
  677.  
  678. var myLabelElementsArray = getElementsByINCT(null, 'myLabel', null, 'vi-display', 'label');
  679. if (myLabelElementsArray.length > 0) {
  680. for (var index = 0; index < myLabelElementsArray.length; index++) {
  681. var myLabelElement = myLabelElementsArray[index];
  682. var wantItLinkElementsArray = myLabelElement.getElementsByTagName('a');
  683. if (wantItLinkElementsArray.length > 0) {
  684. var regexp = /(&|\?|QQ|%26|Q26|_W0QQ)TrackingItemId(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i;
  685.  
  686. var wantItLinkElement = wantItLinkElementsArray[0];
  687. var href = wantItLinkElement.href;
  688. var matches = regexp.exec(href);
  689. if (matches != null) {
  690. var newElement = document.createElement('span');
  691. newElement.innerHTML = '<a class="watchLink" title="Show this item on a Google Map" '
  692. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  693. + matches[3]
  694. + '&asksrc=gm' + version + 'p20b" target="_blank"><u>Map this item</u></a> | ';
  695. myLabelElement.parentNode.insertBefore(newElement, myLabelElement);
  696. }
  697. }
  698. }
  699. }
  700.  
  701. var watchStatusElementsArray = getElementsByINCT(null, 'watchStatus', null, 'vi-wantit-display', 'label');
  702. if (watchStatusElementsArray.length > 0) {
  703. for (var index = 0; index < watchStatusElementsArray.length; index++) {
  704. var watchStatusElement = watchStatusElementsArray[index];
  705. var wantItLinkElementsArray = watchStatusElement.getElementsByTagName('a');
  706. if (wantItLinkElementsArray.length > 0) {
  707. var regexp = /(&|\?|QQ|%26|Q26|_W0QQ)TrackingItemId(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i;
  708.  
  709. var wantItLinkElement = wantItLinkElementsArray[0];
  710. var href = wantItLinkElement.href;
  711. var matches = regexp.exec(href);
  712. if (matches != null) {
  713. var newElement = document.createElement('span');
  714. newElement.innerHTML = '<a class="watchLink" title="Show this item on a Google Map" '
  715. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  716. + matches[3]
  717. + '&asksrc=gm' + version + 'p20c" target="_blank">Map this item</a> | ';
  718. watchStatusElement.parentNode.insertBefore(newElement, watchStatusElement);
  719. }
  720. }
  721. }
  722. }
  723.  
  724. var watchButtonPlaced = false;
  725. var watchButtonStatusElementsArray = getElementsByINCT(null, 'watchButtonStatus', null, 'vi-is-hideDiv', 'label');
  726. if (watchButtonStatusElementsArray.length > 0) {
  727. for (var index = 0; index < watchButtonStatusElementsArray.length; index++) {
  728. var watchButtonStatusElement = watchButtonStatusElementsArray[index];
  729. var watchLinkElementsArray = watchButtonStatusElement.getElementsByTagName('a');
  730. if (watchLinkElementsArray.length > 0) {
  731. var regexp = /(&|\?|QQ|%26|Q26|_W0QQ)TrackingItemId(=|Z|%3D|Q3D)([0-9]{9,12})[^0-9]*/i;
  732.  
  733. var watchLinkElement = watchLinkElementsArray[0];
  734. var href = watchLinkElement.href;
  735. var matches = regexp.exec(href);
  736. if (matches != null) {
  737. var newElement = document.createElement('span');
  738. newElement.innerHTML = '<button class="sfbtn" type="button" title="Show this item on a Google Map" '
  739. + ' onclick="window.open(\'http://www.auctionsearchkit.co.uk/search.php?item='
  740. + matches[3]
  741. + '&asksrc=gm' + version + 'p20e\');">Map this item</button> ';
  742. watchButtonStatusElement.parentNode.insertBefore(newElement, watchButtonStatusElement);
  743. watchButtonPlaced = true;
  744. }
  745. }
  746. }
  747. }
  748.  
  749. if (watchButtonPlaced !== true) {
  750. var watchLinkSpanElementsArray = getElementsByINCT(null, null, null, 'watchlinkSpan', 'span');
  751. if (watchLinkSpanElementsArray.length > 0) {
  752. for (var index = 0; index < watchLinkSpanElementsArray.length; index++) {
  753. var watchLinkSpanElement = watchLinkSpanElementsArray[index];
  754. var wlsAnchorElementsArray = watchLinkSpanElement.getElementsByTagName('a');
  755. if ((wlsAnchorElementsArray != null) && (wlsAnchorElementsArray.length > 0)) {
  756. var newElement = document.createElement('span');
  757. var itemId = getItemIdFromUrl();
  758. if (itemId != null) {
  759. newElement.innerHTML = '<b><a class="watchLink" title="Show this item on a Google Map" '
  760. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  761. + itemId
  762. + '&asksrc=gm' + version + 'p20d" target="_blank">Map this item</a></b> | ';
  763. watchLinkSpanElement.parentNode.insertBefore(newElement, watchLinkSpanElement);
  764. }
  765. }
  766. }
  767. }
  768. }
  769.  
  770. var searchItemElementsArray = getElementsByINCT(null, 'searchBtnAnc', null, 'aBtn-btn', 'span');
  771. if (searchItemElementsArray.length > 0) {
  772. var newElement = document.createElement('td');
  773. newElement.innerHTML = '<input title="Show the results of this search on a Google Map"'
  774. + ' type="button" value="Map-Search"'
  775. + ' style="background-color: #0040b2; color: white; font-weight: bold;"'
  776. + ' onmouseover="this.style.cursor=\'pointer\'" onmouseout="this.style.cursor=\'default\'"'
  777. + ' onclick="var advSearchFormElements = document.getElementsByName(\'adv_search_from\');'
  778. + ' if ((advSearchFormElements != null) && (advSearchFormElements[0] != null)) {'
  779. + ' var url = advSearchFormElements[0].action;'
  780. + ' if ((url == \'\') || (url[0] == \'?\') || (url[0] == \'/\')) {'
  781. + ' url = window.location.href + url; '
  782. + ' }'
  783. + ' var allCtrls = advSearchFormElements[0].elements;'
  784. + ' for (ctrlNum = 0; ctrlNum < allCtrls.length; ctrlNum++) {'
  785. + ' var ctrl = allCtrls[ctrlNum];'
  786. + ' var ctrlType = ctrl.type;'
  787. + ' if (typeof ctrlType != \'undefined\') {'
  788. + ' ctrlType = ctrlType.toLowerCase();'
  789. + ' if ((ctrlType != \'submit\') && (ctrlType != \'reset\') &&'
  790. + ' (ctrlType != \'image\') && (ctrlType != \'button\') &&'
  791. + ' (((ctrlType != \'checkbox\') && (ctrlType != \'radio\')) || (ctrl.checked != false))) {'
  792. + ' url += (url.indexOf(\'?\') >= 0) ? \'&\' : \'?\';'
  793. + ' url += ctrl.name + \'=\' + escape(ctrl.value);'
  794. + ' }'
  795. + ' }'
  796. + ' }'
  797. + ' window.open(\'http://www.auctionsearchkit.co.uk/search.php?\''
  798. + ' + url + \'&asksrc=gm' + version + 'p21\'); }">&nbsp;&nbsp;&nbsp;';
  799. searchItemElementsArray[0].parentNode.parentNode.parentNode.insertBefore(
  800. newElement,
  801. searchItemElementsArray[0].parentNode.parentNode.nextSibling);
  802. }
  803.  
  804. var locationElementsArray = getElementsByINCT(null, null, null, null, 'td',
  805. '(/^\\s*Item location:$/i.test(node.innerHTML) == true) && (/^(infolabel_txt|titlePurchase|inf_lab)$/i.test(node.className) == true)');
  806. for (var index = 0; index < locationElementsArray.length; index++) {
  807. var locationElement = locationElementsArray[index];
  808. var itemId = getItemIdFromUrl();
  809. if (itemId != null) {
  810. locationElement.nextSibling.innerHTML +=
  811. ' | <a title="Show this item on a Google Map" '
  812. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  813. + itemId
  814. + '&asksrc=gm' + version + 'p23" target="_blank">Map this item</a>';
  815. }
  816. }
  817. var locationElementsArray = getElementsByINCT(null, null, null, null, 'div',
  818. '(/^\\s*Item location:/i.test(node.innerHTML) == true)');
  819. for (var index = 0; index < locationElementsArray.length; index++) {
  820. var locationElement = locationElementsArray[index];
  821. var itemId = getItemIdFromUrl();
  822. if (itemId != null) {
  823. locationElement.innerHTML +=
  824. ' | <a title="Show this item on a Google Map" '
  825. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  826. + itemId
  827. + '&asksrc=gm' + version + 'p26" target="_blank">Map this item</a>';
  828. }
  829. }
  830. var askQuestionElementsArray = getElementsByINCT(null, null, null, 'asqLink', 'a');
  831. if (askQuestionElementsArray.length > 0) {
  832. for (var index = 0; index < askQuestionElementsArray.length; index++) {
  833. var askQuestionElement = askQuestionElementsArray[index];
  834. var newElement = document.createElement('div');
  835. var itemId = getItemIdFromUrl();
  836. if (itemId != null) {
  837. newElement.innerHTML = '<a title="Show this item on a Google Map" '
  838. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  839. + itemId
  840. + '&asksrc=gm' + version + 'p24" target="_blank">Map this item</a>';
  841. askQuestionElement.parentNode.className = 's-f-da';
  842. askQuestionElement.parentNode.parentNode.insertBefore(
  843. newElement,
  844. askQuestionElement.parentNode);
  845. }
  846. }
  847. }
  848.  
  849. var subMessageListElementsArray = getElementsByINCT(null, null, null, 'subMsg-disc', 'ul');
  850. if (subMessageListElementsArray.length > 0) {
  851. for (var index = 0; index < subMessageListElementsArray.length; index++) {
  852. var subMessageListElement = subMessageListElementsArray[index];
  853. var newElement = document.createElement('li');
  854. newElement.className = 'subMsg-bulletPadd';
  855. var itemId = getItemIdFromUrl();
  856. if (itemId != null) {
  857. newElement.innerHTML = '<a title="Show this item on a Google Map" '
  858. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  859. + itemId
  860. + '&asksrc=gm' + version + 'p25" target="_blank">Map this item</a>';
  861. subMessageListElement.insertBefore(
  862. newElement,
  863. subMessageListElement.childNodes[0]);
  864. }
  865. }
  866. }
  867.  
  868. var outlineListElementsArray = getElementsByINCT(null, null, null, 'outline_list dft_blt bullets', 'ul');
  869. if (outlineListElementsArray.length > 0) {
  870. for (var index = 0; index < outlineListElementsArray.length; index++) {
  871. var outlineListElement = outlineListElementsArray[index];
  872. var viewItemDetailsElementsArray = getElementsByINCT(outlineListElement,
  873. null,
  874. null,
  875. null,
  876. 'a',
  877. '/^View item details$/i.test(node.innerHTML) == true');
  878. if (viewItemDetailsElementsArray.length > 0) {
  879. var itemId = getItemIdFromUrl(viewItemDetailsElementsArray[0]);
  880. if (itemId != null) {
  881. var newElement = document.createElement('li');
  882. newElement.className = 'bullets normal';
  883. newElement.innerHTML = '<span class="listext"><div class="ddl2-content"><span><a title="Show this item on a Google Map" '
  884. + ' href="http://www.auctionsearchkit.co.uk/search.php?item='
  885. + itemId
  886. + '&asksrc=gm' + version + 'p25" target="_blank">Map this item</a></span></div></span>';
  887. outlineListElement.insertBefore(
  888. newElement,
  889. outlineListElement.childNodes[0]);
  890. }
  891. }
  892. }
  893. }
  894.  
  895. // Make the default Messages topic "Other" and automatically submit it
  896. if (window.location.href.search(/contact\.ebay/i) >= 0) {
  897. var otherElementsArray = getElementsByINCT(null, 'Other', 'cat', null, 'input');
  898. if (otherElementsArray.length > 0) {
  899. var otherElement = otherElementsArray[0];
  900. otherElement.selected = true;
  901. otherElement.click();
  902. // Submit the form
  903. var continueElementsArray = getElementsByINCT(null, null, null, 'ctb', 'input');
  904. if (continueElementsArray.length > 0) {
  905. continueElementsArray[0].click();
  906. } else {
  907. var continueDiv = document.getElementById('continueBtnDiv');
  908. if ((continueDiv != null) && (continueDiv.firstChild != null)) {
  909. continueDiv.firstChild.click();
  910. }
  911. }
  912. }
  913. // Clear the question text
  914. var messageElementsArray = getElementsByINCT(null, 'msg_cnt_cnt', 'msg_cnt_cnt', null, 'textarea');
  915. if (messageElementsArray.length > 0) {
  916. for (var index = 0; index < messageElementsArray.length; index++) {
  917. messageElementsArray[index].value = '';
  918. }
  919. }
  920. }
  921. var otherQElement = document.getElementById('qusetOther_cnt_cnt');
  922. var itemDetailsElement = document.getElementById('itemDetails');
  923. if ((otherQElement != null) && (itemDetailsElement != null)) {
  924. var tlnkElement = itemDetailsElement.firstChild;
  925. if (tlnkElement != null) {
  926. var titleElement = tlnkElement.firstChild;
  927. if (titleElement != null) {
  928. otherQElement.text = titleElement.innerHTML;
  929. }
  930. }
  931. }
  932. // Check if there is already an Email Alerts element (e.g. if the "eBay Supercharged Email Alerts"
  933. // script is already installed as well. If there is, do not do anything here.
  934. var emailAlertsElement = document.getElementById('email_alerts');
  935. if ((emailAlertsElement == null) && (saveSearchElement != null)) {
  936. var currency = '';
  937. var curElement = document.getElementById('sacur');
  938. if (curElement != null) {
  939. var labelElement = curElement.nextSibling;
  940. if (labelElement != null) {
  941. if (labelElement.innerHTML.substring(0, 16) == 'Items listed in ') {
  942. currency = labelElement.innerHTML.substring(16);
  943. }
  944. }
  945. }
  946. var newElement = document.createElement('span');
  947. var defaultSearchTitle = document.title;
  948. var itemsPos = defaultSearchTitle.search(/ items - Get great deals on /i);
  949. if (itemsPos >= 0) {
  950. defaultSearchTitle = defaultSearchTitle.substring(0, itemsPos);
  951. }
  952. var eBayPos = defaultSearchTitle.search(/ \| eBay/);
  953. if (eBayPos >= 0) {
  954. defaultSearchTitle = defaultSearchTitle.substring(0, eBayPos);
  955. }
  956. newElement.innerHTML =
  957. '<table style="position: fixed;'
  958. + '_position: absolute;'
  959. + 'left: 72px;'
  960. + 'top: 100px;'
  961. + '_top: expression(eval(document.body.scrollTop + 96));'
  962. + 'z-index: 999999;'
  963. + 'border-width: 5px;'
  964. + 'border-spacing: 5px;'
  965. + 'border-style: outset;'
  966. + 'border-color: gray;'
  967. + 'border-collapse: separate;'
  968. + 'background-color: white;'
  969. + 'visibility: hidden;"'
  970. + ' id="email_alerts">'
  971. + '<tr>'
  972. + '<td>'
  973. + '<b>Email Alerts</b> - Receive alerts when new items match this search.'
  974. + '</td>'
  975. + '<td align="right" valign="top">'
  976. + '<img src="http://pics.ebaystatic.com/aw/pics/buttons/btnClose_16x16.gif"'
  977. + ' onclick="var emailAlertsTable = document.getElementById(\'email_alerts\');'
  978. + 'if (emailAlertsTable != null) {'
  979. + 'emailAlertsTable.style.visibility = \'hidden\';'
  980. + '}"'
  981. + ' onmouseover="this.style.cursor=\'pointer\'"'
  982. + ' onmouseout="this.style.cursor=\'default\'" />'
  983. + '</td>'
  984. + '</tr>'
  985. + '<tr>'
  986. + '<td>'
  987. + '<table style="border-width: 0px;'
  988. + 'border-spacing: 5px;'
  989. + 'border-collapse: separate;">'
  990. + '<tr>'
  991. + '<td>'
  992. + 'Search&nbsp;Title:'
  993. + '</td>'
  994. + '<td colspan="2">'
  995. + '<input type="text" id="search_title" title="Enter a title for this search" size=50 value="'
  996. + defaultSearchTitle + '"/>'
  997. + '</td>'
  998. + '</tr>'
  999. + '<tr>'
  1000. + '<td>'
  1001. + 'Email&nbsp;Address:'
  1002. + '</td>'
  1003. + '<td colspan="2">'
  1004. + '<input type="text" id="email" title="Email address for receiving alerts" size=50 />'
  1005. + '</td>'
  1006. + '</tr>'
  1007. + '<tr>'
  1008. + '<td>'
  1009. + 'Max&nbsp;Total&nbsp;'
  1010. + (currency != '' ? '(' + currency + ')' : 'Price')
  1011. + ':</td>'
  1012. + '<td>'
  1013. + '<input type="text" id="max_total" title="Maximum total price (optional)" size=10 />'
  1014. + '</td>'
  1015. + '<td align="right">'
  1016. + '<input type="checkbox" id="bin_only"/><font color="red">Buy&nbsp;It&nbsp;Now</font> items only'
  1017. + '</td>'
  1018. + '</tr>'
  1019. + '</table>'
  1020. + '</td>'
  1021. + '</tr>'
  1022. + '<tr>'
  1023. + '<td>'
  1024. + '<input type="button" value="OK"'
  1025. + ' onclick="var emailAlertsTable = document.getElementById(\'email_alerts\');'
  1026. + 'var emailElement = document.getElementById(\'email\');'
  1027. + 'var searchTitleElement = document.getElementById(\'search_title\');'
  1028. + 'var maxTotalElement = document.getElementById(\'max_total\');'
  1029. + 'var binOnlyElement = document.getElementById(\'bin_only\');'
  1030. + 'if ((emailAlertsTable != null) && (emailElement != null) && '
  1031. + '(maxTotalElement != null) && (binOnlyElement != null)) {'
  1032. + 'var email = escape(emailElement.value.replace(/^\\s+|\\s+$/g, \'\'));'
  1033. + 'var searchTitle = escape(searchTitleElement.value.replace(/^\s+|\s+$/g, \'\'));'
  1034. + 'var maxTotal = maxTotalElement.value.replace(/^\\s+|\\s+$/g, \'\');'
  1035. + 'if (maxTotal != \'\') {'
  1036. + 'maxTotal = parseFloat(maxTotal);'
  1037. + '}'
  1038. + 'var binOnly = binOnlyElement.checked;'
  1039. + 'if (/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i.test(email) == false) {'
  1040. + 'alert(\'Not a valid email address?\\nPlease check, correct and retry.\');'
  1041. + '} else if ((maxTotal != \'\') && (isNaN(maxTotal) == true)) {'
  1042. + 'alert(\'Max Total must be a number or blank.\\nPlease check, correct and retry.\');'
  1043. + '} else {'
  1044. + 'emailAlertsTable.style.visibility = \'hidden\';'
  1045. + 'var resultsWindow = window.open(\'http://www.auctionsearchkit.com/startalerts.php?email=\''
  1046. + ' + escape(email) + \'&search=\' + escape(window.location.href)'
  1047. + ' + (searchTitle != \'\' ? escape(\'&asktitle=\' + escape(searchTitle)) : \'\')'
  1048. + ' + (maxTotal != \'\' ? (binOnly == true ? escape(\'&asksatotbinhi=\' + maxTotal) : escape(\'&asksatotprchi=\' + maxTotal)) : \'\')'
  1049. + ' + (binOnly == true ? escape(\'&askbinonly=true\') : \'\')'
  1050. + ' + escape(\'&asksrc=gm' + version + 'p22\')'
  1051. + ', \'_blank\', \'channelmode=yes,directories=no,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=400,height=100\');'
  1052. + 'resultsWindow.moveTo(72,100);'
  1053. + '}'
  1054. + '}"'
  1055. + '/>'
  1056. + '<input type="button" value="Cancel"'
  1057. + ' onclick="var emailAlertsTable = document.getElementById(\'email_alerts\');'
  1058. + 'if (emailAlertsTable != null) {'
  1059. + 'emailAlertsTable.style.visibility = \'hidden\';'
  1060. + '}"/>'
  1061. + '</td>'
  1062. + '</tr>'
  1063. + '</table>';
  1064. saveSearchElement.parentNode.insertBefore(newElement, saveSearchElement);
  1065. var newElement2 = document.createElement('span');
  1066. newElement2.innerHTML = '<span class="saveSearch"><a class="anchor" rel="nofollow" href="javascript:;"'
  1067. + 'title="Receive email alerts when new eBay items match this search."'
  1068. + ' onmouseover="this.style.cursor=\'pointer\'" onmouseout="this.style.cursor=\'default\'"'
  1069. + ' onclick="var emailAlertsTable = document.getElementById(\'email_alerts\');'
  1070. + 'if (emailAlertsTable != null) {'
  1071. + 'emailAlertsTable.style.visibility = \'visible\';'
  1072. + '}'
  1073. + 'return false;">Email Alerts (ASK)</a> </span>';
  1074. saveSearchElement.parentNode.insertBefore(newElement2, saveSearchElement);
  1075. }
  1076.  
  1077. // Add T&D ("Title and Description") checkbox to search inputs that don't already have them
  1078. var searchElementsArray = getElementsByINCT(null, null, null, null, 'input', '/^(satitle|query|_nkw|lred|keywords|field-keywords)$/i.test(node.name) == true');
  1079. if (searchElementsArray.length > 0) {
  1080. afiElement = document.getElementById('afi');
  1081. if (afiElement != null) {
  1082. afiElement.style.width = '90%';
  1083. afiElement.style.overflow = 'visible';
  1084. }
  1085. for (var index = 0; index < searchElementsArray.length; index++) {
  1086. var searchElement = searchElementsArray[index];
  1087.  
  1088. // Remove keywords search max length restriction
  1089. searchElement.removeAttribute('maxLength');
  1090. // Look for parent form
  1091. var formElement = searchElement.parentNode;
  1092. while ((formElement !== null) && (/^form$/i.test(formElement.tagName) == false)) {
  1093. formElement = formElement.parentNode;
  1094. }
  1095. // If parent form found, check whether it already has a title and description input
  1096. if (formElement !== null) {
  1097. var titleAndDescElementsArray = getElementsByINCT(formElement, null, null, null, 'input', '/(^sotextsearched$|^srchdesc$|^LH_TitleDesc$)/i.test(node.name) == true');
  1098. // If no title and description input was found, add one
  1099. if (titleAndDescElementsArray.length == 0) {
  1100. var newElement = document.createElement('span');
  1101. newElement.className = 'afi';
  1102. newElement.innerHTML = '<input id="asktandd" name="LH_TitleDesc" value="1" type="checkbox" title="Include title and description" onclick="var asktandd = this.checked; setTimeout(function(){var me = document.getElementById(\'asktandd\'); me.checked = asktandd; });"><span title="Include title and description">T&D</span> </input>';
  1103. searchElement.parentNode.insertBefore(newElement, searchElement.nextSibling);
  1104. if ((typeof formElement.action == 'string') &&
  1105. (formElement.action.charAt(formElement.action.length - 1) == '/')) {
  1106. formElement.action += 'i.html';
  1107. }
  1108. }
  1109.  
  1110. // Commented out: Don't need to do this since can be set in the "Customise" options.
  1111. // Code left in case it is ever needed in future
  1112. /*// Change number of items per page
  1113. var itemsPerPageElementsArray = getElementsByINCT(formElement, null, '_ipg', null, null, null);
  1114. if (itemsPerPageElementsArray.length > 0) {
  1115. for (ippIndex = 0; ippIndex < itemsPerPageElementsArray.length; ippIndex++) {
  1116. itemsPerPageElementsArray[ippIndex].value = '50';
  1117. }
  1118. } else {
  1119. var newElement = document.createElement('span');
  1120. newElement.innerHTML = '<input id="askitemsperpage" name="_ipg" value="50" type="hidden" />';
  1121. searchElement.parentNode.insertBefore(newElement, searchElement.nextSibling);
  1122. }*/
  1123. // Change sort order
  1124. var sortElementsArray = getElementsByINCT(formElement, null, '_sop', null, null, null);
  1125. if (sortElementsArray.length > 0) {
  1126. for (sopIndex = 0; sopIndex < sortElementsArray.length; sopIndex++) {
  1127. sortElementsArray[sopIndex].value = '15';
  1128. }
  1129. } else {
  1130. var newElement = document.createElement('span');
  1131. newElement.innerHTML = '<input id="asksortorder" name="_sop" value="15" type="hidden" />';
  1132. searchElement.parentNode.insertBefore(newElement, searchElement.nextSibling);
  1133. }
  1134. }
  1135. }
  1136. }
  1137. // Add shorter distance filters
  1138. var sadisElementArray = getElementsByINCT(null, null, '_sadis', null, 'select', null);
  1139. if (sadisElementArray.length > 0) {
  1140. for (var sadIndex = 0; sadIndex < sadisElementArray.length; sadIndex++) {
  1141. var sadElement = sadisElementArray[sadIndex];
  1142. var prependText = '';
  1143. if (sadElement.className == 'saveNameDistDrop') {
  1144. prependText = ' miles';
  1145. }
  1146. var newElement = document.createElement('option');
  1147. newElement.value = '5';
  1148. newElement.innerHTML = '5' + prependText;
  1149. sadElement.insertBefore(newElement, sadElement.firstChild);
  1150. newElement = document.createElement('option');
  1151. newElement.value = '3';
  1152. newElement.innerHTML = '3' + prependText;
  1153. sadElement.insertBefore(newElement, sadElement.firstChild);
  1154. newElement = document.createElement('option');
  1155. newElement.value = '2';
  1156. newElement.innerHTML = '2' + prependText;
  1157. sadElement.insertBefore(newElement, sadElement.firstChild);
  1158. newElement = document.createElement('option');
  1159. newElement.value = '1';
  1160. newElement.innerHTML = '1' + prependText;
  1161. sadElement.insertBefore(newElement, sadElement.firstChild);
  1162. //TODO: Select the correct distance in the dropdown by getting the _sadis parameter value from the URL
  1163. }
  1164. }
  1165. } catch(err) {
  1166. fbLog('Error', err);
  1167. }
  1168.  
  1169. // Update script code taken from "Script Update Checker": http://userscripts.org/scripts/show/20145
  1170. // Credit and many thanks to Jarett for making this free for all to use.
  1171. var SUC_script_num = 27159; // Change this to the number given to the script by userscripts.org (check the address bar)
  1172. try{function updateCheck(forced){if ((forced) || (parseInt(GM_getValue('SUC_last_update', '0')) + 86400000 <= (new Date().getTime()))){try{GM_xmlhttpRequest({method: 'GET',url: 'http://userscripts.org/scripts/source/'+SUC_script_num+'.meta.js?'+new Date().getTime(),headers: {'Cache-Control': 'no-cache'},onload: function(resp){var local_version, remote_version, rt, script_name;rt=resp.responseText;GM_setValue('SUC_last_update', new Date().getTime()+'');remote_version=parseInt(/@uso:version\s*(.*?)\s*$/m.exec(rt)[1]);local_version=parseInt(GM_getValue('SUC_current_version', '-1'));if(local_version!=-1){script_name = (/@name\s*(.*?)\s*$/m.exec(rt))[1];GM_setValue('SUC_target_script_name', script_name);if (remote_version > local_version){if(confirm('There is an update available for the Greasemonkey script "'+script_name+'."\nWould you like to go to the install page now?')){GM_openInTab('http://userscripts.org/scripts/show/'+SUC_script_num);GM_setValue('SUC_current_version', remote_version);}}else if (forced)alert('No update is available for "'+script_name+'."');}else GM_setValue('SUC_current_version', remote_version+'');}});}catch (err){if (forced)alert('An error occurred while checking for updates:\n'+err);}}}GM_registerMenuCommand(GM_getValue('SUC_target_script_name', '???') + ' - Manual Update Check', function(){updateCheck(true);});updateCheck(false);}catch(err){}