您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Creates a "Show questions" button next to the "answered questions" text, if any. Once pressed it opens a new tab of the questions.
当前为
- // ==UserScript==
- // @name Show Amazon Questions button + Show Amazon Questions context menu
- // @author u/iNeedAProperAccount
- // @description Creates a "Show questions" button next to the "answered questions" text, if any. Once pressed it opens a new tab of the questions.
- // It also creates a "Open questions tab" context menu entry.
- // Thanks to u/CaptSkinny, u/lilgeeky, u/Sanpete_in_Utah and u/TTum.
- // How it looks like:
- // https://i.imgur.com/XJYWiQ4.png
- // https://i.imgur.com/2Xm9NC5.png
- // Original thread at: https://old.reddit.com/r/AmazonVine/comments/14aynxt/are_product_question_and_answer_sections_gone/
- // @version 0.2
- // @license MIT License
- // @match *://*.amazon.com/*
- // @match *://*.amazon.ca/*
- // @match *://*.amazon.com.mx/*
- // @match *://*.amazon.co.uk/*
- // @match *://*.amazon.fr/*
- // @match *://*.amazon.de/*
- // @match *://*.amazon.es/*
- // @match *://*.amazon.it/*
- // @match *://*.amazon.nl/*
- // @match *://*.amazon.be/*
- // @match *://*.amazon.lu/*
- // @match *://*.amazon.se/*
- // @match *://*.amazon.pl/*
- // @match *://*.amazon.com.tr/*
- // @match *://*.amazon.ae/*
- // @match *://*.amazon.sa/*
- // @match *://*.amazon.co.jp/*
- // @match *://*.amazon.in/*
- // @match *://*.amazon.sg/*
- // @match *://*.amazon.com.au/*
- // @match *://*.amazon.com.br/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.ca
- // @grant GM_registerMenuCommand
- // @namespace https://greasyfork.org/users/877912
- // ==/UserScript==
- GM_registerMenuCommand("Open Questions tab", contextOpenQuestionsTab, "q");
- const ASK_LINK_ID = "askATFLink";
- const REGEX_PATTERN = "^(http[s]?://[^/]+)/(?:.+?/)?(?:dp|gp/product|asin)/(?:.+?/)?([a-zA-Z0-9]{10})(?:[/?]|$)";
- function getQuestionsUrl() {
- const url = document.URL;
- const regex = new RegExp(REGEX_PATTERN, "i");
- const matches = url.match(regex);
- if (matches) {
- const scheme_and_host = matches[1];
- const asin = matches[2];
- if (scheme_and_host && asin) {
- return `${scheme_and_host}/ask/questions/asin/${asin}`;
- }
- }
- }
- function contextOpenQuestionsTab() {
- const questions_url = getQuestionsUrl();
- if (questions_url) {
- window.open(questions_url, '_blank');
- }
- };
- function openQuestionsTab() {
- const questions_url = getQuestionsUrl();
- if (questions_url) {
- const askATFLink = document.getElementById(ASK_LINK_ID);
- if (askATFLink) {
- const button = document.createElement("button");
- button.innerHTML = "Show Questions";
- button.addEventListener("click", function () {
- window.open(questions_url, '_blank');
- });
- askATFLink.parentNode.insertBefore(button, askATFLink.nextSibling);
- }
- }
- }
- const observer = new MutationObserver(function (mutations) {
- mutations.forEach(function (mutation) {
- if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
- for (let i = 0; i < mutation.addedNodes.length; i++) {
- const addedNode = mutation.addedNodes[i];
- if (addedNode.id === ASK_LINK_ID) {
- openQuestionsTab();
- break;
- }
- }
- }
- });
- });
- const observerConfig = {
- childList: true,
- subtree: true
- };
- observer.observe(document.body, observerConfig);
- openQuestionsTab();