Skip to content

Instantly share code, notes, and snippets.

@panam510
Last active October 28, 2020 02:11
Show Gist options
  • Select an option

  • Save panam510/6d10cb99d867491a1be8891a249b9b53 to your computer and use it in GitHub Desktop.

Select an option

Save panam510/6d10cb99d867491a1be8891a249b9b53 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name automatic All Ok
// @namespace https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53
// @version 0.12.4
// @description try to take over the world!
// @author panam510
// @match https://www2.ms-r.com/MSR/MonitorNew/MyPage/EntryInput.asp*
// @grant none
// @updateURL https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53/raw/ms-r_autook.user.js
// ==/UserScript==
(function () {
'use strict';
//縦方向最大化
window.resizeTo(window.outerWidth, screen.availHeight);
window.moveTo(0, 0);
//純利益。利用金額を払ったのち、残したい謝礼額(100円単位で)
const NET_INCOME = 4000;
const MIN_TRAVEL_COST = 0;
const MAX_TRAVEL_COST = 4900;
//交通費を自動入力しない店舗名、カテゴリー(カテゴリーは表示されていない場合もあるため精度悪し)
const NOT_NEED_TRAVELCOST_SHOPNAME = ["QBハウス"];
const NOT_NEED_TRAVELCOST_CATEGORY = ["ラーメン", "ファーストフード"];
//食べログ検索の際に店名から外す文字列
const NOT_NEED_TABELOG_SHOPNAME = ["第[0-9]+事業部"];
let standardReward = parseInt(safeEval(document.getElementsByClassName("entry_table")[0].rows[0].cells[1].innerText.replace(/(円|プレミアム謝礼|,)/g, "").replace("+", "+"))); //謝礼額(プレミアム謝礼があれば含む)
let minimumPayment = parseInt(document.getElementsByClassName("entry_table")[0].rows[1].cells[1].innerText.replace(/(円以上|,)/g, "")); //利用金額
const travelCostButton = document.getElementById("passion4"); //「4.交通費の支給があったら参加できます!」
const notIncludeShopNameRegex = new RegExp(NOT_NEED_TABELOG_SHOPNAME.join("|"));
const notNeedShopNameRegex = new RegExp(NOT_NEED_TRAVELCOST_SHOPNAME.join("|"));
const notNeedShopCategoryRegex = new RegExp(NOT_NEED_TRAVELCOST_CATEGORY.join("|"));
const shopName = document.getElementsByClassName("entry_shopInfo_name")[0].textContent.replace(notIncludeShopNameRegex, '').replace('_', ' ');
const shopDiv = document.body.getElementsByClassName('entry_shopName_Wrap')[0];
const shopCategory = document.getElementsByClassName("label label-default")[0].textContent;
for (let row of document.getElementsByClassName("entry_table")[0].rows) {
const rowName = row.cells[0].innerText;
if (rowName == "謝礼額") {
if (row.cells[1].innerText.includes("%")) {
standardReward = 0;
} else {
standardReward = parseInt(safeEval(row.cells[1].innerText.replace(/(円|プレミアム謝礼|,)/g, "").replace("+", "+"))); //謝礼額(プレミアム謝礼があれば含む)
}
} else if (rowName == "利用金額") {
minimumPayment = parseInt(row.cells[1].innerText.replace(/(円以上|,)/g, "")); //利用金額
break;
}
}
if (document.getElementById("PassionHopeCost") != null) {
const standardBalance = minimumPayment - standardReward; //謝礼額-利用金額の差し引き
const travelCostList = document.getElementById("PassionHopeCost").options; //交通費0円~5000円の配列
const isStandardPayment = minimumPayment != 1 && !isNaN(minimumPayment); //利用金額が「1円以上」や空白だったらfalse、それ以外ならtrue
//交通費のリストに情報を付加
for (let i = 0; i < travelCostList.length; i++) {
let addedReward = parseInt(travelCostList[i].value) - standardBalance; //差額(利用金額-(謝礼額+交通費))算出
const summedReward = parseInt(travelCostList[i].value) + standardReward; //合計額(謝礼額+交通費)算出
const passionRewardRatio = (parseInt(travelCostList[i].value) / standardReward * 100).toFixed(1); //割合(交通費÷謝礼額)算出、小数点第1位までで四捨五入
if (isStandardPayment) {
const rewardPaymentRatio = (summedReward / minimumPayment * 100).toFixed(1); //割合(合計額÷利用金額)算出、小数点第1位までで四捨五入
//交通費支給額欄に差額・合計額・割合を足す
if (addedReward > 0) {
addedReward = "+" + addedReward;
} else if (addedReward == 0) {
addedReward = "±" + addedReward;
} else if (addedReward < 0) {
addedReward = addedReward.toString().replace("-", "-");
}
travelCostList[i].text += "(標準謝礼+" + passionRewardRatio + "%、合計謝礼" + summedReward + "円、利用金額比" + rewardPaymentRatio + "%、差引" + addedReward + "円)";
} else {
//利用金額が「1円以上」や空白だったら差額と割合(合計額÷利用金額)はあまり意味がないので、合計額・割合(交通費÷謝礼額)を足す
travelCostList[i].text += "(標準謝礼+" + passionRewardRatio + "%、合計謝礼" + summedReward + "円)";
}
}
if (!travelCostButton.disabled &&
!notNeedShopNameRegex.test(shopName) &&
!notNeedShopCategoryRegex.test(shopCategory)) {
//交通費希望のラジオボタンを押す
travelCostButton.click();
if (isStandardPayment) {
const hopeTravelCost = Math.ceil((standardBalance + NET_INCOME) / 100) * 100; //上乗せとして求める金額(100円単位切り上げ)
if (hopeTravelCost > MAX_TRAVEL_COST) {
//5000円出しても届かなければ5000円要求
document.getElementById("PassionHopeCost").value = MAX_TRAVEL_COST.toString();
} else if (hopeTravelCost < MIN_TRAVEL_COST) {
//0円でも上回っていれば0円要求
document.getElementById("PassionHopeCost").value = MIN_TRAVEL_COST.toString();
} else {
//純利益を加味した額の交通費を要求
document.getElementById("PassionHopeCost").value = hopeTravelCost.toString();
}
} else {
// 利用金額が「1円以上」や空白のとき、とりあえず5000円乗せる
document.getElementById("PassionHopeCost").value = MAX_TRAVEL_COST.toString();
}
}
}
//食べログへのリンク追加
for (let i = 0; i < shopDiv.getElementsByTagName('a').length; i++) {
const existATag = shopDiv.getElementsByTagName('a')[i];
if (existATag.textContent.includes("店舗サイト") &&
!existATag.href.includes("tabelog.com")) {
let newATag = document.createElement('a');
let hrefURI = new URL('https://tabelog.com/rstLst/?');
let params = new URLSearchParams;
params.set('sk', encodeURI(shopName.trim()))
params.set('hfc', '1')
params.set('sw', encodeURI(shopName.trim()))
newATag.href = hrefURI + params;
newATag.target = '_blank'
newATag.classList.add('btn', 'btn-xs', 'btn-default');
newATag.appendChild(document.createTextNode('食べログ'));
document.body.getElementsByClassName('entry_shopName_Wrap')[0].appendChild(newATag);
}
}
//ここから自動入力処理
if (!document.getElementsByClassName("entry_topBox")[0].innerText.match(/調査内容をご確認の上、『エントリーする』ボタンを押してエントリーしてください。/)) {
if (!document.getElementsByClassName("entry_topBox")[0].innerText.match(/調査に当選しました。おめでとうございます!/)) {
//初期エントリー時のみ自動入力を有効とする(入力ミス時、およびエントリー内容変更時などは自動入力処理を行わない)
return;
} else {
//承諾画面の処理
const methodFurikomi = document.getElementsByName("PointMethod")[0]; //銀行振込
const methodEGift = document.getElementsByName("PointMethod")[1]; //選べるe-GIFT
if (methodFurikomi != null) {
//銀行振り込みをデフォルトとする。
//選べるe-GIFTをデフォルトにしたい場合は、この上下2つの「methodFurikomi」を「methodEGift」に書き換える
methodFurikomi.click();
}
}
}
const allOkFlag = document.getElementById("allokFlag"); //「調査の内容をすべて確認しました。」
if (!allOkFlag.disabled) {
//「すべて確認しました。」にチェックを入れる
allOkFlag.click();
}
//交通費欄に飛ばす。気分で
//document.getElementById("PassionHopeCost").focus();
function safeEval(val) {
return Function('"use strict";return (' + val + ')')();
}
})();
// ==UserScript==
// @name copy report to clipboard
// @namespace https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53
// @version 0.0.1
// @description try to take over the world!
// @author panam510
// @match https://www2.ms-r.com/MSR/MS_Global/Report/ReportInput.asp*
// @grant none
// @updateURL https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53/raw/ms-r_clip.user.js
// ==/UserScript==
(function() {
'use strict';
let aTag = document.createElement('a');
aTag.href = 'javascript:void(0);';
aTag.onclick = parseHTML;
aTag.classList.add('btn','btn-sm','btn-info');
aTag.appendChild(document.createTextNode('コピー'));
document.body.getElementsByTagName('div')[0].getElementsByTagName('div')[0].appendChild(aTag);
function parseHTML() {
let parseResult = "\t利用金額\t\t合計\t=SUM(E2:E26)*1.1\n\t謝礼金額\t\n\t入店時刻\t\n\t着席時刻\t\n\t退店時刻\t\n\t会計金額\t\n\tクーポン利用額\t\n\t座席位置\t\n\t混雑状況\t\n";
var parser = new DOMParser();
var doc = parser.parseFromString(document.body.innerHTML, "text/html");
var q1h1h2 = doc.querySelectorAll(".q1tb1, .h1td2, .h2td1, .h1td3"); // 欲しい要素のクラス。q1が質問事項、h1/h2が小見出し
for (var i = 0; i < q1h1h2.length; i++) { // 取得したクラスを上から順に処理
if (q1h1h2[i].className.indexOf("q1tb1") != -1) { // 質問事項のクラスだった場合に行う処理
var q1td1 = q1h1h2[i].getElementsByClassName('q1td1'); // tdセルの内容を一括で取得
// 質問タイプ。質問テーブル内に該当する要素があるかどうかで判定
var hasIframe = q1h1h2[i].querySelector("iframe") != null; // お写真添付用のiframe
var hasTextArea = (q1h1h2[i].querySelector("textarea") != null && q1h1h2[i].querySelector("textarea").rows > 1); // textareaで書かせる長いテキスト
var hasTextBox = (q1h1h2[i].querySelector("input[type='text']") != null || (q1h1h2[i].querySelector("textarea") != null && q1h1h2[i].querySelector("textarea").rows == 1)); // input type=textか、row1のtextareaで書かせる短いテキスト
for (var j = 0; j < q1td1.length; j++) { // tdセルを上から順番に処理
if (RegExp(/^Q\d+\.$/).test(q1td1[j].textContent)) { // 質問番号(Q1.など)のセル
switch (true) {
case hasIframe: // お写真
parseResult += q1td1[j].textContent + "📷\t";
break;
case hasTextArea: // 長テキスト
parseResult += q1td1[j].textContent + "📝\t";
break;
case hasTextBox: // 短テキスト
parseResult += q1td1[j].textContent + "🖊️\t";
break;
default: // それ以外(ラジオボタンなど)
parseResult += q1td1[j].textContent + "️\t";
break;
}
} else if (q1td1[j].textContent.trim() == "") { // 空欄のセル。タブだけ入れる
parseResult += "️\t";
} else { // 質問内容の本体が入っているセル。まず末尾に空行があれば除去、途中の改行にはタブを挿入する
parseResult += q1td1[j].innerText.replace(/\n$/g, '').replace(/^\n/gm, '').replace(/\n/g, "\n\t") + "\n";
}
}
} else if (q1h1h2[i].className.indexOf("h1td3") != -1) { // 小見出し下の備考。小見出しの右に出したい
parseResult = parseResult.replace(/\n$/g, "\t\t") + q1h1h2[i].textContent + "\n";
} else { // 質問ではないセル=小見出し。そのまま内容を入れて改行
parseResult += q1h1h2[i].textContent + "\n";
}
}
navigator.clipboard.writeText(parseResult);
alert("copied!");
}
})();
// ==UserScript==
// @name copy summary to clipboard
// @namespace https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53
// @version 0.0.1
// @description try to take over the world!
// @author panam510
// @match https://www2.ms-r.com/MSR/MonitorNew/MyPage/MyResearchList.asp*
// @grant none
// @updateURL https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53/raw/ms-r_clip2.user.js
// ==/UserScript==
(function () {
'use strict';
let divDD = document.querySelectorAll("div [id^=DD]");
for (let i = 0; i < divDD.length; i++) {
let aTag = document.createElement('a');
aTag.href = 'javascript:void(0);';
aTag.onclick = function () { copySummary(divDD[i].getElementsByTagName("table")[0].rows); };
aTag.classList.add('btn', 'btn-sm', 'btn-info');
aTag.appendChild(document.createTextNode('コピー'));
divDD[i].getElementsByTagName("table")[0].rows[0].cells[1].appendChild(aTag);
}
function copySummary(elm) {
let copyText = "";
let isHeader = 1;
for (let i = 1; i < elm.length; i++) {
const row = elm[i];
if (row.cells[0].innerText.includes("調査フロー・注意事項")) {
isHeader = 0;
}
if (isHeader) {
if (row.cells.length == 1) {
copyText += row.cells[0].innerText.trim() + "\n";
} else {
copyText += row.cells[0].innerText.trim() + "\t";
let cell1Text = row.cells[1].innerText.trim();
if (i == 2) {
cell1Text = cell1Text.replace(/\n店舗サイト*/, '');
}
if (/^\d+$/.test(cell1Text)) {
cell1Text = "'" + cell1Text;
}
if (cell1Text.includes("\n")) {
copyText += "\"" + cell1Text + "\"\n";
} else {
copyText += cell1Text + "\n";
}
}
} else {
let cell0Text = row.cells[0].innerText;
cell0Text = cell0Text.trim().replace(/^\n/gm, '');
copyText += cell0Text + "\n";
}
}
navigator.clipboard.writeText(copyText);
alert("copied!");
}
})();
// ==UserScript==
// @name Feedback page autoscroll
// @namespace https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53
// @version 0.1
// @description try to take over the world!
// @author panam510
// @match https://www2.ms-r.com/MSR/MonitorNew/MyPage/MyFB.asp*
// @grant none
// @updateURL https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53/raw/ms-r_fbscroll.user.js
// ==/UserScript==
(function() {
'use strict';
//縦方向最大化
window.resizeTo(window.outerWidth, screen.availHeight);
window.moveTo(0, 0);
//最下部へ移動
const element = document.documentElement;
const bottom = element.scrollHeight - element.clientHeight;
window.scroll(0, bottom);
})();
// ==UserScript==
// @name Hide unnecessary projects
// @namespace https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53
// @version 0.3
// @description try to take over the world!
// @author panam510
// @match https://www2.ms-r.com/MSR/MonitorNew/MyPage/EntryList.asp*
// @grant none
// @updateURL https://gist.github.com/panam510/6d10cb99d867491a1be8891a249b9b53/raw/ms-r_hideunnec.user.js
// ==/UserScript==
(function() {
'use strict';
const NOT_NEED_WORDS = ["エントリー済", "とりいちず"];
const notNeedWordsRegex = new RegExp(NOT_NEED_WORDS.join("|"));
const searchResultEasy = document.getElementsByClassName("searchShopInfoEasy")[0];
const searchResultDetail = document.getElementsByClassName("searchShopDetail");
if(searchResultEasy != null){
for (let i = 1; i < searchResultEasy.children[0].rows.length; i++) {
const row = searchResultEasy.children[0].rows[i];
if (notNeedWordsRegex.test(row.textContent)) {
row.style.display = "none";
}
const src = row.cells[6].getElementsByTagName("img")[0].src;
switch (true) {
case src.includes("ic_blue_easy.png"):
row.cells[6].innerText = "低";
break;
case src.includes("ic_yellow_easy.png"):
row.cells[6].innerText = "中";
break;
case src.includes("ic_red_easy.png"):
row.cells[6].innerText = "高";
break;
default:
break;
}
}
}
if(searchResultDetail.length > 0){
for (let i = 0; i < searchResultDetail.length; i++) {
const div = searchResultDetail[i];
if (notNeedWordsRegex.test(div.textContent)) {
div.style.display = "none";
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment