// ==UserScript==
// @name 何も選択していない状態でCtrl+Cでページのタイトル+改行+URL+改行をクリップボードにコピー
// @description Amazonや静画(漫画)やGoogle検索ならURLの無駄を削る ニコ動・静画・Web漫画アンテナのマイリスト画面ならリストの列挙をコピー(押すたびにソート条件変更) Shift+Cで除去文字列設定 Calil検索・yahooテレビ検索・駿河屋検索ならタイトルに検索ワードを挿入
// @match *://*/*
// @version 0.4.5
// @grant none
// @namespace https://greasyfork.org/users/181558
// @downloadURL none
// ==/UserScript==
(function() {
var sakujoRE = localStorage.getItem("ctrlcsakujoRE") || "";
var cckaisuu = 0;
document.addEventListener("keydown", function(e) { //キー入力
if (/input|textarea/i.test(e.target.tagName)) return;
if (!e.shiftKey && !e.altKey && !e.ctrlKey && e.which == 65 && /www\.nicovideo\.jp\/my\/mylist/.test(location.href)) { // ニコ動マイリストでAで全てチェック
for (let a of elegeta('//div[@class="checkBoxOuter"]/input[@name="checkbox"]')) a.click();
return;
}
if (e.shiftKey && !e.altKey && !e.ctrlKey && e.which == 67) { // shift+C 除去文字列設定
var str = prompt("shift+C:\r\n\"" + document.domain + "\" で Ctrl+C 押下時タイトルやURLや選択文字列から除去したい文字列を正規表現で入力してください\r\n\r\n現在値:" + sakujoRE + "\r\n", sakujoRE);
sakujoRE = str === null ? sakujoRE : str;
if (sakujoRE != "") { localStorage.setItem("ctrlcsakujoRE", sakujoRE); } else { localStorage.removeItem("ctrlcsakujoRE"); }
return;
}
if (!e.shiftKey && !e.altKey && e.ctrlKey && e.which == 67) { // ctrl+c
if (window.getSelection() != "") {
//選択文字列がある
var selection=window.getSelection().toString();
if(sakujoRE){
selection=selection.replace(RegExp(sakujoRE, "gm"), ""); // Shift+C 除去文字列を除去
if(window.getSelection().toString()!==selection) copy2cb(selection);
}
popup("" + selection.length + "文字:
" + selection + "
");
return;
}
var doc = location.href;
var txt1 = doc;
var txt2 = txt1;
if (/www\.amazon\.co\.jp\/|www\.amazon\.com\//.test(txt1) && (txt1.indexOf("/dp/") != -1)) // Amazonの余計なパラメータ除去
txt2 = "https://"+document.domain+"/dp/" + txt1.substr(txt1.indexOf("/dp/") + 4, 10);
if ((txt1.indexOf("www.amazon.co.jp/") != -1) && (txt1.indexOf("/ASIN/") != -1))
txt2 = "https://www.amazon.co.jp/dp/" + txt1.substr(txt1.indexOf("/ASIN/") + 6, 10);
if (/\/\/www\.google\.co\.jp\/search\?|\/\/www\.google\.com\/search\?/.test(txt1)) { // google検索結果のパラメータ除去
var para = txt1.split(/[&?]/);
txt2 = para[0] + "?";
var j = 0;
for (var i = 1; i < para.length; i++) {
console.log(para[i]);
var a = para[i].replace(/^ei=.*/, "").replace(/^oq=.*/, "").replace(/^gs_l=.*/, "").replace(/^hl=ja/, "").replace(/^source=.*/, "").replace(/^sa=.*/, "").replace(/^ved=.*/, "").replace(/^biw=.*/, "").replace(/^bih=.*/, "").replace(/^dpr=.*/, "").replace(/^ie=.*/, "").replace(/^oe=.*/, "").replace(/^client=.*/, "").replace(/^aqs=.*/, "").replace(/^sourceid=.*/, "");
if (a !== "") { txt2 += (j > 0 ? "&" : "") + a; j++; }
}
}
if (/seiga\.nicovideo\.jp\/comic/.test(txt1)) txt2 = txt1.replace(/\?track=.*/, ""); // 静画(マンガ)短縮
if (/seiga\.nicovideo\.jp\/watch\/mg/.test(txt1)) txt2 = txt1.replace(/\?track=.*/, "");
if (/www\.youtube\.com\/embed\//.test(txt1)) txt2 = txt1.replace(/\?.*/, "").replace(/embed\//, "watch?v="); // youtube埋め込み //document.referrer;//
var titleOption = addtitle(/calil.jp\/local\/search/, txt1, '//form[@class="search"]/div/input|//input[@id="query"]'); //,'//div[@class="message"]',/$^/," | "); // calil検索
titleOption += addtitle(/tv\.yahoo\.co\.jp\/search\/\?q=/, txt1, '//input[@class="generic_inputText floatl"]'); // yahooテレビ検索
if(document.title.indexOf("|")===-1) titleOption += addtitle(/www\.suruga-ya\.jp\/search\?/, txt1, '//input[@id="searchText"]','//div[@id="topicPath"]',/駿河屋TOP.≫.|駿河屋TOP/gi); // 駿河屋検索
var ret = (navigator.platform.indexOf("Win") != -1) ? "\r\n" : "\n";
var title = titleOption + document.title.replace(/ https?:.*/, "");
title = title.replace(RegExp(sakujoRE, "g"), ""); // Shift+C 除去文字列を除去
txt2 = txt2.replace(RegExp(sakujoRE, "g"), "");
if (cckaisuu % 1 == 0) { var txt = title + ret + txt2 + ret; var bal = "" + title + "