-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: spokik-dev-events
Are you sure you want to change the base?
Changes from 1 commit
b0b8462
1bd5e02
f20eb6c
8eed0a5
56fa94a
943851b
d9b9d26
ac973a2
b9c8756
396c8c2
d6be03a
8af5fef
fc222e0
41f14aa
10dbe84
ee18327
27e0310
cb6f254
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const script = document.createElement('script');// create new element script as module | ||
script.setAttribute("type", "module"); | ||
script.setAttribute("src", chrome.extension.getURL('kad.js')); | ||
const testModule = document.createElement(`script`) | ||
testModule.setAttribute("type", "module") | ||
testModule.setAttribute("src", chrome.extension.getURL('./modules/alert.js')) | ||
|
||
const head = document.head || document.getElementsByTagName("head")[0] || document.documentElement; | ||
head.insertBefore(script, head.lastChild);// add module in head | ||
head.insertBefore(testModule, head.lastChild); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
| ||
"use strict"; | ||
"use strict"; | ||
|
||
import { injectFunction } from './my-script.js'; | ||
import { windowForUserScript } from './modules/alert.js'; | ||
if (document.location.href === `https://kad.arbitr.ru/`) { windowForUserScript() } | ||
injectFunction(); | ||
|
||
|
||
|
||
if (document.location.href != `https://kad.arbitr.ru/`) { | ||
let usersSettings = JSON.parse(localStorage.getItem(`usersSettings`)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try to keep one pattern of quotes, single or double or backward. Usually, if you have just a string use the single quotes |
||
if (usersSettings == undefined) { | ||
usersSettings = { | ||
|
@@ -442,7 +451,7 @@ | |
}); | ||
observer.observe(elem, { | ||
attributes: true, | ||
childList: true | ||
childList: true | ||
}) | ||
}) | ||
promise.catch((err) => { console.error(`Error: `, err) }) | ||
|
@@ -520,5 +529,5 @@ | |
return stringReturn | ||
} | ||
|
||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
|
||
//Функция создает поля для воода года и номера дела | ||
function windowForUserScript() { | ||
let div = document.createElement('div'); | ||
div.id = "UserScriptIndex"; | ||
div.innerHTML = `А40 - | ||
<input value="" type ="text" class="b-selected-tags" placeholder = "номер дела" id = "NumberWithoutA40" > | ||
<fieldset> | ||
<label> | ||
<input type="button" name="inputYear" value="20" id="year20" checked="checked"> </label> | ||
<label><input type="button" name="inputYear" value="19" id="year19"> | ||
</label><label><input type="button" name="inputYear" value="18" id="year18"> | ||
</label></fieldset>`; | ||
document.getElementById('b-form-submit').before(div); | ||
// document.getElementById('main-column1').before(div); | ||
let getNumberInput = document.getElementById(NumberWithoutA40); | ||
|
||
getNumberInput.oninput = zamena(); | ||
function zamena() { | ||
document.getElementById('dich').innerHTML = getNumberInput.value; | ||
|
||
let a40 = document.getElementById(NumberWithoutA40).value; | ||
let year20 = document.getElementById(year20).checked; | ||
let year19 = document.getElementById(year19).checked; | ||
let year18 = document.getElementById(year18).checked; | ||
let year = 20; | ||
|
||
if (year20 == true) { year = 20; } | ||
else if (year19 == true) { year = 19; } | ||
else if (year18 == true) { year = 18; } | ||
else { alert(`ЕРОР! Чет какая - то шляпа введина в место года`) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use ternary operators here |
||
|
||
let fullNumber = "А40-" + a40 + "-" + year; | ||
document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value = fullNumber; | ||
} | ||
|
||
let tooOldYear = document.getElementById(NumberWithoutA40).value; | ||
//Устанавливаем по умолчанию А40-88888-20 | ||
document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value = А40 - 88888 - 20; | ||
//пересобирает строку, заменя 2 последний цифры | ||
function setYear(year) { | ||
let newNumber = document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value | ||
let inString = document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value["length"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't like the name XD |
||
var getNewNumber = `` | ||
let i = 0 | ||
while (inString - 2 > i) { | ||
getNewNumber = getNewNumber + newNumber[i] | ||
i++ | ||
} | ||
getNewNumber = getNewNumber + year | ||
return getNewNumber | ||
} | ||
|
||
|
||
//Красим фон и меняем год | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you use comments, it means you use bad names ;) |
||
document.getElementById("year20").onclick = function orange() { document.getElementById('main-column1').style.background = "#ffcf65"; document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value = setYear(20); }; | ||
document.getElementById("year19").onclick = function orange() { document.getElementById('main-column1').style.background = "#7cf99d"; document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value = setYear(19); }; | ||
document.getElementById("year18").onclick = function orange() { document.getElementById('main-column1').style.background = "#86cdff"; document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value = setYear(18); }; | ||
document.getElementById("pager1").onclick = function orange() { document.getElementById('main-column1').style.background = "#e9f0fa";; };//Красив в сток по праву тех | ||
}; | ||
|
||
export { windowForUserScript }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
const injectFunction = () => window.alert('hello, world'); | ||
|
||
export { injectFunction }; |
There was a problem hiding this comment.
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