Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

me first a pull request #7

Open
wants to merge 18 commits into
base: spokik-dev-events
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .unotes/unotes_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "",
"isOrdered": true,
"folders": {
"modules": {
"name": "modules",
"isOrdered": true,
"folders": {},
"files": {}
}
},
"files": {
"README": 0
}
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Kad.arbitr

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should be instructions how to run your application in Readme

Пользовательский скрипт, пока не имеющий названия. Создан для сканировщиков, загружающих на сайт необходимые дела.

Функции

МД по умолчанию:
При добавлении иска на сайт, скрипт автоматически указывает тип документа.
При добавлении иска на сайт, скрипт автоматически указывает тип документа.

Горячие шаблоны:
При отсудствии зарегестрированного документа в базе, сканеровщику необходимо создать собственную карточку. Скрипт позволяет как указать быстро сторону (истца, либо ответчика) Либо заполнить все поля ( Отзыв, заявление о праавоприемстве, ходатойство о приобщении дополнительных материалов дела и так далее.
При отсудствии зарегестрированного документа в базе, сканеровщику необходимо создать собственную карточку. Скрипт позволяет как указать быстро сторону (истца, либо ответчика) Либо заполнить все поля ( Отзыв, заявление о праавоприемстве, ходатойство о приобщении дополнительных материалов дела и так далее.

Проверка повторной загрузки:
При попытке загрузить один и тот же фаил в разные дела, скрипт сообщит о потенциальной ошибке.
При попытке загрузить один и тот же фаил в разные дела, скрипт сообщит о потенциальной ошибке.

Статистика:
скрипт собирает статистику о загруженных документах. Имеет возможность построть таблицу по составам и дням.

скрипт собирает статистику о загруженных документах. Имеет возможность построть таблицу по составам и дням.
520 changes: 520 additions & 0 deletions ScanOldScritpForTamtermonkey

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { windowForUserScript } from './modules/selectYear.js';
import { defaultMD } from './modules/autoMD.js';
import { addBattons } from './modules/addBattons.js';
import { addTamplaties } from './modules/addTamplaties.js';
import { usersSettings } from './modules/usersSettings.js'
import { checkReload } from './modules/checkReload.js'
import { statisticsInterface } from './modules/statisticsInterface.js'
import { addStaticOnLocalStorage } from './modules/addStaticOnLocalStorage.js'


export {
windowForUserScript,
defaultMD,
addBattons,
addTamplaties,
addStaticOnLocalStorage,
usersSettings,
checkReload,
statisticsInterface
}
34 changes: 34 additions & 0 deletions kad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

"use strict";
import {
windowForUserScript,
defaultMD,
addBattons,
addTamplaties,
addStaticOnLocalStorage,
usersSettings,
checkReload,
statisticsInterface
} from './index.js'

if (document.location.href === `https://kad.arbitr.ru/`) { windowForUserScript() }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings that contain url are better to be stored into const


if (document.location.href != `https://kad.arbitr.ru/`) {

window.onload = onloadPage();

function onloadPage() {
addBattons()
statisticsInterface()
if (usersSettings.autoMD == "checked") { defaultMD() }
if (usersSettings.tamplaties == "checked") { addTamplaties() }
if (usersSettings.checkReload == "checked") { checkReload() }
if (usersSettings.statCollect == "checked") { addStaticOnLocalStorage() }
if (false) {
//Тут будет выбора составов пользателя
}

}

}

39 changes: 39 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "kad4scan",
"version": "2.0.0",
"description": "kad4scan - extensions for work in kad as scanner",
"permissions": [
"https://*.tribalwars2.com/game.php*"
],
"icons": {
"128": "overflow.png"
},
"browser_action": {
"default_icon": "overflow.png"
},
"content_scripts": [
{
"js": [
"modules.js"
],
"matches": [
"https://*.kad.arbitr.ru/Card/*",
"https://*.kad.arbitr.ru/*"
],
"run_at": "document_end"
}
],
"web_accessible_resources": [
"kad.js",
"index.js",
"modules/selectYear.js",
"modules/autoMD.js",
"modules/addBattons.js",
"modules/addTamplaties.js",
"modules/checkReload.js",
"modules/statisticsInterface.js",
"modules/addStaticOnLocalStorage.js",
"modules/usersSettings.js"
],
"manifest_version": 2
}
20 changes: 20 additions & 0 deletions modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';
const head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;

createNewScript('kad.js')
createNewScript('./modules/autoMD.js')
createNewScript('./modules/selectYear.js')
createNewScript('./modules/addBattons.js')
createNewScript('./modules/addTamplaties.js')
createNewScript('./modules/checkReload.js')
createNewScript('./modules/statisticsInterface.js')
createNewScript('./modules/addStaticOnLocalStorage.js')


function createNewScript(url) {
const name = document.createElement('script')
name.setAttribute("type", "module");
name.setAttribute("src", chrome.extension.getURL(url))
head.insertBefore(name, head.lastChild);
}

55 changes: 55 additions & 0 deletions modules/addBattons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { usersSettings } from './usersSettings.js'

// Добавляет кнопки пользовательского интерфейса
function addBattons() {
let footer = document.createElement("div")
footer.className = "b-feedback"
let xc = sostavPerDay(usersSettings.usersSS)
footer.innerHTML = `${xc} <div id="activeStat" class="tampleteButton" style="height:23px">Статистика</div>`;

let classBlok = document.createElement("style")
classBlok.innerHTML = "div.tampleteButton{height: 30px;width: 130px;-webkit-appearance: button;-webkit-writing-mode: horizontal-tb !important;color: buttontext;text-shadow: none;display: inline-block;text-align: center;align-items: flex-start;background-color: buttonface;box-sizing: border-box;margin: 0em;font: 400 13.3333px Arial;padding: 1px 6px;border-width: 2px;border-style: outset;border-color: buttonface;border-image: initial;}}";
let divBlok = document.createElement("div")
divBlok.id = "UserTempale"
divBlok.innerHTML = `
<div id="istec" class="tampleteButton" >Истец</div>
<div id="otvetchik" class="tampleteButton">Ответчик</div>
<div id="PoObshimPravilam" class="tampleteButton">По общим</div>
<div id="Clarify" class="tampleteButton">Уточнение.И</div>
<br>
<div id="hodOPriob" class="tampleteButton">Приобщении.И</div>
<div id="Otziv" class="tampleteButton">Отзыв.О</div>
<div id="otkazOtIska" class="tampleteButton">Отказ.И</div>
<div id="processualnoePravopriemstvo" class="tampleteButton">Правоприемство</div>`;

document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > div.b-popup-button.js-upload-submit").before(classBlok)
document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > div.b-popup-button.js-upload-submit").before(divBlok)
document.querySelector("#b-footer > div > div.b-copyright").after(footer)
}

//получает масив составов, вовзращает строку " состав: штук | состав: штук ..."
function sostavPerDay(sostavs) {
let today = new Date().getDate()
let month = new Date().getMonth() + 1
let counter = {}
for (let index = 0; index < sostavs.length; index++) {
let starArray = JSON.parse(localStorage.getItem(`sostav${sostavs[index]}`))
for (let key in starArray) {
if (starArray[key].month == month) {
if (starArray[key].day == today) {
if (counter[sostavs[index]] == undefined) { counter[sostavs[index]] = 0 }
counter[sostavs[index]]++
}
}
}
}
//string stringify
let stringReturn = ''
for (let key in counter) {

stringReturn = stringReturn + `${key} состав: ${counter[key]} штук | `
}
return stringReturn
}

export { addBattons }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check please the spelling of the filename ;)

119 changes: 119 additions & 0 deletions modules/addStaticOnLocalStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { usersSettings } from './usersSettings.js'

// Добавляет статистику по загрузкам в localStorage
function addStaticOnLocalStorage() {
let elem = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload")

let promise = new Promise((resolve, reject) => {
let observer = new MutationObserver((mutationRecords) => {
if (mutationRecords.length > 1) {
let saveScanStat = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > div.b-popup-button.js-upload-submit"); // кнопка по которой срабатывает скрипт
let q = document.querySelector("#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div").childElementCount //Кол-во элементов для фикла
let sostav = ' состав неопределен'
let docId = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > input[type=hidden]:nth-child(4)").value

//it's selector for add new document without the card
//document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > input[type=hidden]:nth-child(4)").value
let a40 = document.querySelector("#b-case-header > ul.crumb.g-ec > li > span").textContent.split(" ")[20]


for (let i = 1; i < q; i++) {
if (document.querySelector(`#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(${i}) > div.r-col > h2 > a > span`) !== null) {
let checker = document.querySelector(`#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(${i}) > div.r-col > h2 > a `)
.textContent //полуучает текст
.trim() //Удаляет пробелы "с краёв"
.split(` `) //Правращает в масив по разделителю " "
let stringValueCounter = 0
if (stringValueCounter < 2) {
for (let i = 0; i < checker.length; i++) {
if (checker[i] === `О` ||
checker[i] === `принятии` ||
checker[i] === `производству`) { stringValueCounter++ }
}
}

if (stringValueCounter > 2) {
sostav = document.querySelector("#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(" + i + ") > div.r-col > h2 > span > p:nth-child(1)")
.textContent
.trim() //Удаляет пробелы "с краёв"
.split(` `) //Правращает в масив по разделителю " "
.pop() //"вырезает" последний элемент масива
} else if (sostav !== ' состав неопределен') {
// console.log(`Состав:`, sostav, `идем дальше`)
}
else { sostav = ' состав неопределен' }
}
}
if(document.querySelector(`#userSS`) === null){
sostavAtPopup(sostav)
}


let params = {
saveScanStat: saveScanStat,
sostav: sostav,
docId: docId,
a40: a40,
}
resolve(params)

} else if (mutationRecords.length === 1) {
return console.log(`Атрибуты изменились`, mutationRecords, `- Закрытие модального окна`)
}
});
observer.observe(elem, {
attributes: true,
childList: true
})
})
promise.catch((err) => { console.error(`Error: `, err) })
.then((params) => {

//Срабатывает прии НАЖАТИИ на "Сохранить"
params.saveScanStat.onclick = () => {
let now = new Date()
let dataForLS = {}
dataForLS = JSON.parse(localStorage.getItem(`sostav${params.sostav}`))
if (dataForLS == null) {
dataForLS = {};
}
dataForLS[params.docId] = {
day: `${now.getDate()}`,
month: `${1 + now.getMonth()}`,
a40: `${params.a40}`,
}
localStorage.setItem(`sostav${params.sostav}`, JSON.stringify(dataForLS)
)
}
})

function sostavAtPopup(sostav) {
const elem = document.createElement("div")
elem.className = "b-popup-info"
elem.innerHTML = `<div class="b-popup-info-title" id="userSS">Состав</div><span class="b-popup-info-text js-popup-info-text" title="${sostav}">${sostav}</span>`
let isYourSostav = false
function isCorrectSostav() {
for (let i = 0; i < usersSettings.usersSS.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the content of this loop can be written just in one line with the help of the ternary operation:
for (let i = 0; i < usersSettings.usersSS.length; i++) { return (isYourSostav = usersSettings.usersSS[i] == sostav ? true : false); }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also below состав неопределен is it should be necessary the phrase with space before??

if (usersSettings.usersSS[i] == sostav) {
isYourSostav = true
return
} else {
isYourSostav = false

}
}
}
isCorrectSostav()
if (sostav === ` состав неопределен` || !isYourSostav) {
elem.innerHTML = `<div class="b-popup-info-title">Состав</div><span class="b-popup-info-text js-popup-info-text" id="SSOnPop" title="${sostav}">${sostav}</span>`
elem.style.color = "red"
}
if (document.querySelector(`#SSOnPop`) !== null) { } else { document.querySelector("div.js-popup-info_attributes").append(elem) }



}
}


export { addStaticOnLocalStorage }
57 changes: 57 additions & 0 deletions modules/addTamplaties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Добавляет обработчики интерфейса

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should apply VS formatter here. It's unreadable at all

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploading image.png…

function addTamplaties() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name :)

//получаем стороны
const applicantl1 = document.querySelector("#gr_case_partps > table > tbody > tr > td.plaintiffs.first > div > ul > li > span > a").innerText; //Истец
const applicantl2 = document.querySelector("#gr_case_partps > table > tbody > tr > td.defendants > div > ul > li > span > a").innerText; //Ответчик

//События меняют стороны
document.getElementById("istec").onclick = () => (document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > dl > dd > div > span > label > input").value = applicantl1);
document.getElementById("otvetchik").onclick = () => (document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > dl > dd > div > span > label > input").value = applicantl2);
//События Вставляют даные шблонов
document.getElementById("Otziv").onclick = () => pastValuesFromTamplate(tamplatesValue.otziv.value, tamplatesValue.otziv.licantl, tamplatesValue.otziv.showText);
document.getElementById("hodOPriob").onclick = () => pastValuesFromTamplate(tamplatesValue.HodOPriob.value, tamplatesValue.HodOPriob.licantl, tamplatesValue.HodOPriob.showText);
document.getElementById("otkazOtIska").onclick = () => pastValuesFromTamplate(tamplatesValue.OtmenaIska.value, tamplatesValue.OtmenaIska.licantl, tamplatesValue.OtmenaIska.showText);
document.getElementById("processualnoePravopriemstvo").onclick = () => pastValuesFromTamplate(tamplatesValue.processual.value, tamplatesValue.processual.licantl, tamplatesValue.processual.showText);
document.getElementById("PoObshimPravilam").onclick = () => pastValuesFromTamplate(tamplatesValue.PoObshimPravilam.value, tamplatesValue.PoObshimPravilam.licantl, tamplatesValue.PoObshimPravilam.showText);
document.getElementById("Clarify").onclick = () => pastValuesFromTamplate(tamplatesValue.Clarify.value, tamplatesValue.Clarify.licantl, tamplatesValue.Clarify.showText);
function pastValuesFromTamplate(value, licantl, showText) {
document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > table > tbody > tr > td.b-popup-sj-table-item.b-popup-sj-table-item--name > dl > dd > select > option").value = value;
document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > dl > dd > div > span > label > input").value = licantl;
document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > table > tbody > tr > td.b-popup-sj-table-item.b-popup-sj-table-item--name > dl > dd > a > span.selectBox-label").innerHTML = showText;
}
//Данные для заполнения шаблонов
const tamplatesValue = {
otziv: {
value: `47c2f1f0-014f-44da-8ee7-f53c09fdf182`,
licantl: applicantl2,
showText: `Отзыв`,
},
HodOPriob: {
value: `725a6e6a-76dd-49a2-abf0-dd2eaf5f2cca`,
licantl: applicantl1,
showText: `Ходатайство о приобщении к делу дополнительных документов`,
},
OtmenaIska: {
value: `3e1e0fe8-5ab8-4c7d-af98-cb2ab3d5cf6f`,
licantl: applicantl1,
showText: `Ходатайство об отказе от иска`,
},
processual: {
value: `64c6b878-d3e5-4b93-92ed-d41880b217d2`,
licantl: applicantl2,
showText: `Заявление о процессуальном правопреемстве`,
},
PoObshimPravilam: {
value: `c8c5bdb7-5335-474e-9a49-55ca44250525`,
licantl: applicantl2,
showText: `Ходатайство о рассмотрении дела по общим правилам искового производства`,
},
Clarify: {
value: `07388172-ff14-4517-848b-0a07649f334d`,
licantl: applicantl1,
showText: `Ходатайство об уточнении размера исковых требований`,
},
};
}

export { addTamplaties }
Loading