Amazon search MAM

Add "Search MAM" button to Amazon

当前为 2018-01-27 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Amazon search MAM
// @namespace    https://greasyfork.org/en/users/78880
// @version      0.1
// @description  Add "Search MAM" button to Amazon
// @author       Slengpung
// @include      https://www.amazon.com/*
// @grant        none
// ==/UserScript==

var ul;

// If this is a book, inject search-button
try {
	var tmm = document.getElementById("tmmSwatches");
	ul = tmm.getElementsByTagName("ul")[0];
	console.log("MAM plugin: Looks like a book! Injecting MAM box...");
}
catch(err) {
	console.log("MAM plugin: This does not look like a book, won't inject search button!");
	return;
}

// Grab title
var title = document.getElementById("title").getElementsByTagName("span")[0].innerHTML;

// Create search-box
var li = document.createElement("li");
li.className += "swatchElement unselected resizedSwatchElement";
var span = document.createElement("span");
span.className += "a-button a-button-selected a-spacing-mini a-button-toggle format";
var a = document.createElement("a");
a.href = "https://www.myanonamouse.net/tor/browse.php?tor[text]=" + title;
a.target = "_new";
var text = document.createTextNode("Search MAM");
a.appendChild(text);
span.appendChild(a);
span.style.cssText += "height: 50px; padding: 5px 10px; background: #EDB91F; color: black";
li.appendChild(span);

// Inject title-search on page
ul.appendChild(li);