Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ページのタイトルやURLをクリップボードにコピーするだけのパッチ。

 - Amazonの長いURLを短くしてコピーできるよう機能追加
  • Loading branch information...
commit 8b8bdaef7c167c8a2c5f377f49d39a118d76b03c 1 parent 1ee2d48
@polygonplanet authored
Showing with 27 additions and 4 deletions.
  1. +27 −4 tombloo.service.actions.copytitle.js
View
31 tombloo.service.actions.copytitle.js
@@ -8,13 +8,14 @@
* [Service Actions Copy Title patch]
*
* - ページのタイトルやURLをクリップボードにコピーする
+ * - Amazonの長いURLを短くしてコピーする
*
* --------------------------------------------------------------------------
*
- * @version 1.00
- * @date 2011-10-20
- * @author polygon planet <polygon.planet@gmail.com>
- * - Blog : http://polygon-planet.blogspot.com/
+ * @version 1.01
+ * @date 2012-08-09
+ * @author polygon planet <polygon.planet.aqua@gmail.com>
+ * - Blog : http://polygon-planet-log.blogspot.com/
* - Twitter : http://twitter.com/polygon_planet
* - Tumblr : http://polygonplanet.tumblr.com/
* @license Same as Tombloo
@@ -49,6 +50,10 @@ const LABELS = {
MENU_COPY_URL : {
ja : 'このページのURLをコピー',
en : 'Copy the page URL'
+ },
+ MENU_COPY_AMAZON : {
+ ja : 'AmazonのURLを短くしてコピー',
+ en : 'Copy the short Amazon URL'
}
};
@@ -91,6 +96,24 @@ Tombloo.Service.actions.register({
execute : function(ctx) {
copyString(ctx.href);
}
+ }, {
+ name : LABELS.translate('MENU_COPY_AMAZON'),
+ type : 'context',
+ check : function(ctx) {
+ return ctx && ctx.href && /(?:^|\b)amazon\b/i.test(ctx.host);
+ },
+ execute : function(ctx) {
+ let asin = function() {
+ return ctx.document.getElementById('ASIN') ||
+ ctx.document.getElementsByName('ASIN.0')[0] ||
+ {value : ''};
+ }().value,
+ href = ('' + ctx.href) || '',
+ re = /^(https?:\/+[^\/]+\/).*$/,
+ url = asin && href.replace(re, '$1dp/' + asin) || 'error';
+
+ copyString(url);
+ }
}]
}, '----');
Please sign in to comment.
Something went wrong with that request. Please try again.