...
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
{
|
||||
sequences: {
|
||||
"www.nhmembers.co.kr/nhaob": [".btn-direct-menu"],
|
||||
"multicon.co.kr/couponMall/order/info":[
|
||||
{ target: () => document.querySelector(".point_inquiry").click(), wait: 5000 },
|
||||
{ action: () => {
|
||||
if(document.querySelector(".result_point").innerText.split("P")[0] > 0) {
|
||||
location.href = "${NH_DOMAIN + APP_LOG}"
|
||||
}
|
||||
}, wait: 15000 },
|
||||
],
|
||||
"multicon.co.kr/couponMall/goodsDetail":[
|
||||
{ target: () => document.querySelector(".grey_btn").click(), wait: 5000 }
|
||||
],
|
||||
"multicon.co.kr/couponMall/main":[
|
||||
{ target: () => document.querySelector(".product").parentElement.click(), wait: 5000 }
|
||||
],
|
||||
"example.com/login": [
|
||||
// 1. [순수 함수] 아이디 입력 (실행 후 바로 다음 스텝으로)
|
||||
{ action: () => { document.querySelector(".userid-input").value = "test_id"; } },
|
||||
|
||||
// 2. [순수 함수 + 대기] 비밀번호 입력 후 1초 대기
|
||||
{
|
||||
action: () => { document.querySelector(".password-input").value = "1234!!"; },
|
||||
wait: 1000
|
||||
},
|
||||
|
||||
// 3. [클릭 액션] 로그인 버튼 클릭 (기존 방식들 모두 호환됨)
|
||||
"#login-btn",
|
||||
{ target: () => document.getElementById("confirm-modal"), wait: 2000 }
|
||||
],
|
||||
"mysite.com/survey": ["input[value='yes']", "button.next-step"],
|
||||
},
|
||||
blacklist: {
|
||||
"any": ["logout", "delete", "remove", "exit","header__prev main_header"],
|
||||
"runcomm.co.kr": [".adpot_inquiry", ",btn_com1", "닫기"]
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -129,3 +129,75 @@ window.addEventListener('error', function(event) {
|
||||
console.warn('Resource Load Error:', target.src || target.href);
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
||||
function kkk(){
|
||||
var sss = document.getElementsByTagName('meta');
|
||||
for(i=0;i<sss.length;i++) {
|
||||
if(sss[i].name.includes("viewport")) {
|
||||
console.log(sss[i]);
|
||||
sss[i].remove();
|
||||
}
|
||||
}
|
||||
|
||||
var meta = document.createElement('meta'); meta.setAttribute( 'name', 'viewport' ); meta.setAttribute( 'content', 'width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 4.0, user-scalable = yes, viewport-fit=cover' );
|
||||
document.getElementsByTagName('head')[0].appendChild(meta);
|
||||
var meta = document.createElement('meta'); meta.setAttribute( 'name', 'viewport' ); meta.setAttribute( 'content', 'width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 4.0, user-scalable = yes, viewport-fit=cover' );
|
||||
document.getElementsByTagName('head')[0].appendChild(meta);
|
||||
}
|
||||
|
||||
let scale = 1.0; // 현재 확대 비율
|
||||
let startDistance = 0; // 터치 시작 시점의 두 손가락 거리
|
||||
let baseScale = 1.0; // 터치 시작 시점의 기존 확대 비율
|
||||
|
||||
// 두 손가락 사이의 거리를 계산하는 함수 (피타고라스 정리 활용)
|
||||
function getDistance(touch1, touch2) {
|
||||
const dx = touch1.clientX - touch2.clientX;
|
||||
const dy = touch1.clientY - touch2.clientY;
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
const target = document.body;
|
||||
|
||||
// transform이 일어날 기준점을 왼쪽 상단(0,0)으로 고정
|
||||
target.style.transformOrigin = "0 0";
|
||||
target.style.transition = "transform 0.05s ease-out"; // 부드러운 애니메이션 효과
|
||||
|
||||
// 1. 터치 시작 (두 손가락이 닿았을 때)
|
||||
window.addEventListener('touchstart', (e) => {
|
||||
if (e.touches.length === 2) {
|
||||
// 기본 브라우저 줌인 동작 방지
|
||||
e.preventDefault();
|
||||
|
||||
startDistance = getDistance(e.touches[0], e.touches[1]);
|
||||
baseScale = scale; // 현재 배율을 기준으로 저장
|
||||
}
|
||||
}, { passive: false });
|
||||
|
||||
// 2. 터치 이동 (손가락을 벌리거나 오므릴 때)
|
||||
window.addEventListener('touchmove', (e) => {
|
||||
if (e.touches.length === 2) {
|
||||
e.preventDefault();
|
||||
|
||||
const currentDistance = getDistance(e.touches[0], e.touches[1]);
|
||||
if (startDistance > 0) {
|
||||
// 거리 비율만큼 배율 계산
|
||||
const distanceRatio = currentDistance / startDistance;
|
||||
let newScale = baseScale * distanceRatio;
|
||||
|
||||
// 최소 1배 ~ 최대 3배까지만 확대 제한 (원하는 대로 조절 가능)
|
||||
newScale = Math.max(1.0, Math.min(newScale, 3.0));
|
||||
|
||||
scale = newScale;
|
||||
target.style.transform = `scale(${scale})`;
|
||||
console.log('Scale: ', + target.style.transform);
|
||||
}
|
||||
}
|
||||
}, { passive: false });
|
||||
|
||||
// 3. 터치 종료 (손가락을 뗐을 때)
|
||||
window.addEventListener('touchend', (e) => {
|
||||
if (e.touches.length < 2) {
|
||||
startDistance = 0; // 거리 초기화
|
||||
}
|
||||
});
|
||||
@@ -1,22 +1,305 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<title>Config Generator</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: #f4f7f8; padding: 20px; color: #333; }
|
||||
.container { max-width: 900px; margin: 0 auto; }
|
||||
h1, h2 { color: #2c3e50; }
|
||||
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
||||
|
||||
<script type="text/javascript">
|
||||
window.addEventListener('load', () => {
|
||||
history.pushState(null, '', location.href);
|
||||
window.addEventListener('popstate', function(event){
|
||||
console.log("Got event");
|
||||
});
|
||||
console.log("addEventListener");
|
||||
});
|
||||
</script>
|
||||
/* Drag & Drop 영역 */
|
||||
.drop-zone { border: 2px dashed #3498db; border-radius: 8px; padding: 30px; text-align: center; background: #ebf5fb; color: #2980b9; font-weight: bold; cursor: pointer; transition: background 0.3s; margin-bottom: 20px; }
|
||||
.drop-zone.dragover { background: #d6eaf8; border-color: #2980b9; }
|
||||
|
||||
.url-block { border: 1px solid #e1e8ed; padding: 15px; border-radius: 6px; margin-bottom: 15px; position: relative; background: #fafbfc; }
|
||||
.remove-btn { position: absolute; right: 15px; top: 15px; background: #ff4757; color: white; border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; }
|
||||
|
||||
.step-block { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px dashed #ccc; padding: 10px; border-radius: 4px; margin-top: 10px; }
|
||||
.step-block select, .step-block input, .step-block textarea { padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
|
||||
.step-block .code-input { flex-grow: 1; }
|
||||
.step-block textarea { width: 100%; height: 60px; font-family: monospace; resize: vertical; }
|
||||
.step-block .wait-input { width: 100px; }
|
||||
|
||||
.btn { background: #2ed573; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-weight: bold; margin-top: 10px; }
|
||||
.btn-add { background: #1e90ff; }
|
||||
.btn-generate { background: #3742fa; font-size: 16px; padding: 12px 20px; width: 48%; }
|
||||
.btn-export { background: #f39c12; font-size: 16px; padding: 12px 20px; width: 48%; float: right; }
|
||||
|
||||
input[type="text"] { width: 300px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
|
||||
|
||||
pre { background: #2f3542; color: #f1f2f6; padding: 20px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; }
|
||||
.btn-row { display: flex; justify-content: space-between; margin-top: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h1>봇 설정(Config) 생성기</h1>
|
||||
|
||||
<div id="dropZone" class="drop-zone">
|
||||
📂 여기에 JSON 백업 파일을 드래그하거나 클릭하여 불러오세요.
|
||||
<input type="file" id="fileInput" accept=".json" style="display: none;">
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>1. Sequences (순차 처리)</h2>
|
||||
<div id="sequences-container"></div>
|
||||
<button class="btn btn-add" onclick="addSequenceUrl()">+ URL 추가</button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>2. Blacklist (클릭 제외)</h2>
|
||||
<div id="blacklist-container"></div>
|
||||
<button class="btn btn-add" onclick="addBlacklistUrl()">+ 블랙리스트 URL 추가</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn btn-generate" onclick="generateCode()">🚀 JS 코드 생성하기</button>
|
||||
<button class="btn btn-export" onclick="exportJson()">💾 프로젝트 JSON 저장</button>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-top: 20px;">
|
||||
<h2>결과 코드 (앱 삽입용)</h2>
|
||||
<pre><code id="outputCode">// 여기에 자바스크립트 코드가 생성됩니다.</code></pre>
|
||||
<button class="btn" onclick="copyCode()">코드 복사하기</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let sequenceCounter = 0;
|
||||
let stepCounter = 0;
|
||||
let blacklistCounter = 0;
|
||||
|
||||
// --- 초기 샘플 데이터 ---
|
||||
const sampleData = {
|
||||
sequences: {
|
||||
"multicon.co.kr/couponMall/order/info": [
|
||||
{ type: "target", value: "document.querySelector('.point_inquiry').click()", wait: "5000" },
|
||||
{ type: "action", value: 'if(document.querySelector(".result_point").innerText.split("P")[0] > 0) {\n location.href = "${NH_DOMAIN + APP_LOG}";\n}', wait: "15000" }
|
||||
]
|
||||
},
|
||||
blacklist: {
|
||||
"any": ["logout", "delete", "remove", "exit", "header__prev main_header"],
|
||||
"runcomm.co.kr": [".adpot_inquiry", ",btn_com1", "닫기"]
|
||||
}
|
||||
};
|
||||
|
||||
// --- DOM 생성 로직 ---
|
||||
function addSequenceUrl(url = '') {
|
||||
const id = sequenceCounter++;
|
||||
const container = document.getElementById('sequences-container');
|
||||
const html = `
|
||||
<div class="url-block" id="seq-${id}">
|
||||
<button class="remove-btn" onclick="document.getElementById('seq-${id}').remove()">삭제</button>
|
||||
<label><strong>URL 키워드:</strong></label>
|
||||
<input type="text" class="seq-url" placeholder="예: example.com/login" value="${url}">
|
||||
<div id="steps-container-${id}" style="margin-top: 15px;"></div>
|
||||
<button class="btn btn-add" style="background:#57606f;" onclick="addStep(${id})">+ 스텝(Step) 추가</button>
|
||||
</div>
|
||||
`;
|
||||
container.insertAdjacentHTML('beforeend', html);
|
||||
return id;
|
||||
}
|
||||
|
||||
function addStep(urlId, stepData = { type: 'string', value: '', wait: '' }) {
|
||||
const sId = stepCounter++;
|
||||
const container = document.getElementById(`steps-container-${urlId}`);
|
||||
const html = `
|
||||
<div class="step-block" id="step-${sId}">
|
||||
<select class="step-type" onchange="changeStepType(${sId})">
|
||||
<option value="string" ${stepData.type === 'string' ? 'selected' : ''}>기본 클릭 (문자열)</option>
|
||||
<option value="target" ${stepData.type === 'target' ? 'selected' : ''}>동적 타겟 (Target)</option>
|
||||
<option value="action" ${stepData.type === 'action' ? 'selected' : ''}>순수 함수 (Action)</option>
|
||||
</select>
|
||||
<div id="step-input-area-${sId}" style="flex-grow: 1; display: flex; gap: 10px;"></div>
|
||||
<button class="remove-btn" style="position:static;" onclick="document.getElementById('step-${sId}').remove()">X</button>
|
||||
</div>
|
||||
`;
|
||||
container.insertAdjacentHTML('beforeend', html);
|
||||
|
||||
changeStepType(sId, stepData.value, stepData.wait);
|
||||
}
|
||||
|
||||
function changeStepType(sId, defaultValue = '', defaultWait = '') {
|
||||
const type = document.querySelector(`#step-${sId} .step-type`).value;
|
||||
const area = document.getElementById(`step-input-area-${sId}`);
|
||||
|
||||
// 기존 값이 있다면 보존, 없다면 인자값 사용
|
||||
const existingInput = area.querySelector('.seq-val');
|
||||
const existingWait = area.querySelector('.wait-input');
|
||||
const val = existingInput ? existingInput.value : defaultValue;
|
||||
const wait = existingWait ? existingWait.value : defaultWait;
|
||||
|
||||
if (type === 'string') {
|
||||
area.innerHTML = `<input type="text" class="code-input seq-val" placeholder='CSS 선택자 (예: .btn-login)' value="${val}">`;
|
||||
} else if (type === 'target') {
|
||||
area.innerHTML = `
|
||||
<div style="flex-grow:1;">
|
||||
<span style="font-family:monospace; font-size:12px;">() => </span>
|
||||
<input type="text" class="code-input seq-val" style="width: calc(100% - 40px);" placeholder="document.querySelector('.btn')" value="${val}">
|
||||
</div>
|
||||
<input type="number" class="wait-input" placeholder="Wait(ms)" value="${wait}">
|
||||
`;
|
||||
} else if (type === 'action') {
|
||||
area.innerHTML = `
|
||||
<textarea class="code-input seq-val" placeholder="if(condition) { location.href='...'; }">${val}</textarea>
|
||||
<input type="number" class="wait-input" placeholder="Wait(ms)" value="${wait}">
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
function addBlacklistUrl(url = '', tagsArray = []) {
|
||||
const id = blacklistCounter++;
|
||||
const container = document.getElementById('blacklist-container');
|
||||
const tags = tagsArray.join(', ');
|
||||
const html = `
|
||||
<div class="url-block" id="bl-${id}">
|
||||
<button class="remove-btn" onclick="document.getElementById('bl-${id}').remove()">삭제</button>
|
||||
<label><strong>URL 키워드:</strong></label>
|
||||
<input type="text" class="bl-url" placeholder="예: any 또는 특정 URL" value="${url}">
|
||||
<div style="margin-top: 10px;">
|
||||
<label><strong>제외 키워드:</strong> (콤마 ',' 로 구분)</label><br>
|
||||
<input type="text" class="bl-tags" style="width: 100%; margin-top:5px;" placeholder="logout, delete" value="${tags}">
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
container.insertAdjacentHTML('beforeend', html);
|
||||
}
|
||||
|
||||
// --- JSON Load & Export 로직 ---
|
||||
function loadFromJson(data) {
|
||||
document.getElementById('sequences-container').innerHTML = '';
|
||||
document.getElementById('blacklist-container').innerHTML = '';
|
||||
|
||||
if (data.sequences) {
|
||||
for (const [url, steps] of Object.entries(data.sequences)) {
|
||||
const urlId = addSequenceUrl(url);
|
||||
steps.forEach(step => addStep(urlId, step));
|
||||
}
|
||||
}
|
||||
if (data.blacklist) {
|
||||
for (const [url, tags] of Object.entries(data.blacklist)) {
|
||||
addBlacklistUrl(url, tags);
|
||||
}
|
||||
}
|
||||
generateCode();
|
||||
}
|
||||
|
||||
function extractCurrentData() {
|
||||
const data = { sequences: {}, blacklist: {} };
|
||||
|
||||
document.querySelectorAll('[id^="seq-"]').forEach(urlBlock => {
|
||||
const url = urlBlock.querySelector('.seq-url').value.trim();
|
||||
if (!url) return;
|
||||
data.sequences[url] = [];
|
||||
|
||||
urlBlock.querySelectorAll('.step-block').forEach(stepBlock => {
|
||||
const type = stepBlock.querySelector('.step-type').value;
|
||||
const val = stepBlock.querySelector('.seq-val').value.trim();
|
||||
const waitInput = stepBlock.querySelector('.wait-input');
|
||||
const wait = waitInput && waitInput.value ? waitInput.value : "";
|
||||
|
||||
if (val) data.sequences[url].push({ type, value: val, wait });
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('[id^="bl-"]').forEach(blBlock => {
|
||||
const url = blBlock.querySelector('.bl-url').value.trim();
|
||||
const tags = blBlock.querySelector('.bl-tags').value.split(',').map(t => t.trim()).filter(t => t);
|
||||
if (url && tags.length > 0) data.blacklist[url] = tags;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function exportJson() {
|
||||
const data = extractCurrentData();
|
||||
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(data, null, 2));
|
||||
const downloadAnchorNode = document.createElement('a');
|
||||
downloadAnchorNode.setAttribute("href", dataStr);
|
||||
downloadAnchorNode.setAttribute("download", "config_project.json");
|
||||
document.body.appendChild(downloadAnchorNode);
|
||||
downloadAnchorNode.click();
|
||||
downloadAnchorNode.remove();
|
||||
}
|
||||
|
||||
// --- 자바스크립트 코드(앱용) 생성 로직 ---
|
||||
function generateCode() {
|
||||
const data = extractCurrentData();
|
||||
let code = "const config = {\n sequences: {\n";
|
||||
|
||||
for (const [url, steps] of Object.entries(data.sequences)) {
|
||||
code += ` "${url}": [\n`;
|
||||
steps.forEach(step => {
|
||||
const waitStr = step.wait ? `, wait: ${step.wait}` : '';
|
||||
if (step.type === 'string') {
|
||||
code += ` "${step.value}",\n`;
|
||||
} else if (step.type === 'target') {
|
||||
code += ` { target: () => ${step.value}${waitStr} },\n`;
|
||||
} else if (step.type === 'action') {
|
||||
const formattedVal = step.value.includes('\n') ? `\n ${step.value.replace(/\n/g, '\n ')}\n ` : step.value;
|
||||
code += ` { action: () => { ${formattedVal} }${waitStr} },\n`;
|
||||
}
|
||||
});
|
||||
code += ` ],\n`;
|
||||
}
|
||||
|
||||
code += " },\n blacklist: {\n";
|
||||
for (const [url, tags] of Object.entries(data.blacklist)) {
|
||||
const tagsStr = tags.map(t => `"${t}"`).join(', ');
|
||||
code += ` "${url}": [${tagsStr}],\n`;
|
||||
}
|
||||
code += " }\n};";
|
||||
|
||||
document.getElementById('outputCode').textContent = code;
|
||||
}
|
||||
|
||||
function copyCode() {
|
||||
const text = document.getElementById('outputCode').textContent;
|
||||
navigator.clipboard.writeText(text).then(() => alert('코드가 복사되었습니다!'));
|
||||
}
|
||||
|
||||
// --- Drag & Drop 파일 업로드 로직 ---
|
||||
const dropZone = document.getElementById('dropZone');
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
|
||||
dropZone.addEventListener('click', () => fileInput.click());
|
||||
dropZone.addEventListener('dragover', (e) => { e.preventDefault(); dropZone.classList.add('dragover'); });
|
||||
dropZone.addEventListener('dragleave', () => dropZone.classList.remove('dragover'));
|
||||
dropZone.addEventListener('drop', (e) => {
|
||||
e.preventDefault();
|
||||
dropZone.classList.remove('dragover');
|
||||
if (e.dataTransfer.files.length) handleFile(e.dataTransfer.files[0]);
|
||||
});
|
||||
fileInput.addEventListener('change', (e) => {
|
||||
if (e.target.files.length) handleFile(e.target.files[0]);
|
||||
});
|
||||
|
||||
function handleFile(file) {
|
||||
if (!file.name.endsWith('.json')) {
|
||||
alert('JSON 파일만 업로드 가능합니다.');
|
||||
return;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
try {
|
||||
const json = JSON.parse(e.target.result);
|
||||
loadFromJson(json);
|
||||
alert('데이터를 성공적으로 불러왔습니다.');
|
||||
} catch (err) {
|
||||
alert('JSON 파싱에 실패했습니다: ' + err.message);
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
// --- 초기 실행 ---
|
||||
window.onload = () => {
|
||||
loadFromJson(sampleData);
|
||||
};
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
</html>
|
||||
Vendored
+13
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user