您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Puts your own Amazon affiliate ID in Amazon links
- // ==UserScript==
- // @name Use My Amazon Affiliate Code
- // @namespace http://www.lysator.liu.se/~jhs/userscript
- // @description Puts your own Amazon affiliate ID in Amazon links
- // @include http://*
- // @include https://*
- // @version 0.0.1.20180814201445
- // ==/UserScript==
- // leave intact to sponsor my scripting, or set to your own:
- const affiliate = 'skeagxmvv-20';
- const at_amazon = /(.*\.)?amazon\.(com|[a-z]{2}(\.[a-z]{2})?)$/i;
- const aff_links = /(obidos.(ASIN.{12}([^\/]*(=|%3D)[^\/]*\/)*|redirect[^\/]*.(tag=)?))[^\/&]+/i;
- if( location.hostname.match( at_amazon ) )
- return;
- var i, l, p;
- for( i=0; l=document.links[i]; i++ )
- {
- if( !l.hostname.match( at_amazon ) || !l.hostname.match( /^www\./i ) )
- continue;
- if( l.href.match( aff_links ) )
- l.href = l.href.replace( aff_links, '$1'+affiliate );
- else if( !l.search )
- {
- p = encodeURIComponent( l.pathname.substring( 1 ) + l.search );
- l.search = '?tag='+ affiliate +'&path='+ p;
- l.pathname = '/exec/obidos/redirect';
- }
- }