Amazon search MAM

Add "Search MAM" button to Amazon

目前為 2018-01-27 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);