Last active
September 7, 2021 18:00
-
-
Save and-rom/7def3e0ef56c0a8222442b71022203cf to your computer and use it in GitHub Desktop.
myparcels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name myparcels | |
| // @namespace https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf | |
| // @version 0.1.10 | |
| // @author and-rom | |
| // @description Minor style changes. Paste date from clipboard to parcel add form by pressing Alt+Shift+V | |
| // @homepage https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf | |
| // @icon https://myparcels.ru/favicon.png | |
| // @icon64 https://myparcels.ru/favicon.png | |
| // @updateURL https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf/raw/myparcels.meta.js | |
| // @downloadURL https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf/raw/myparcels.user.js | |
| // @match http*://myparcels.ru/* | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name myparcels | |
| // @namespace https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf | |
| // @version 0.1.10 | |
| // @author and-rom | |
| // @description Minor style changes. Paste date from clipboard to parcel add form by pressing Alt+Shift+V | |
| // @homepage https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf | |
| // @icon https://myparcels.ru/favicon.png | |
| // @icon64 https://myparcels.ru/favicon.png | |
| // @updateURL https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf/raw/myparcels.meta.js | |
| // @downloadURL https://gist.github.com/and-rom/7def3e0ef56c0a8222442b71022203cf/raw/myparcels.user.js | |
| // @match http*://myparcels.ru/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| setTimeout(function() { | |
| var leftColumn = document.getElementById('leftColumn'); | |
| leftColumn.style.width = "100%"; | |
| leftColumn.style.float = "none"; | |
| }, 500); | |
| var obj,cb,dd,on,pt,sh; | |
| document.addEventListener('keydown', function(e) { | |
| var code = (e.keyCode ? e.keyCode : e.which); | |
| if (e.altKey && e.shiftKey && code==86) { //Alt+Shift+v | |
| navigator.clipboard.readText() | |
| .then(text => { | |
| console.log('Pasted content: ', text); | |
| obj = JSON.parse(text); | |
| console.log(obj); | |
| if (document.getElementById('parcel-add-dialog')) { | |
| console.log('Adding'); | |
| document.getElementById('parcel-add-tracking').value = obj.trackNo; | |
| cb = document.getElementById('checkbox-parcel-add-dispute-deadline-enabled'); | |
| if (cb.checked != true) cb.click(); | |
| dd = document.querySelector('input.parcel-add-dispute-deadline'); | |
| on = document.getElementById('parcel-add-orderno'); | |
| pt = document.getElementById('parcel-add-title'); | |
| } else if (document.getElementById('parcel-edit-dialog')) { | |
| console.log('Editing'); | |
| cb = document.getElementById('checkbox-dispute-deadline-enabled'); | |
| if (cb.checked != true) cb.click(); | |
| dd = document.querySelector('input[name="disputeDeadline"]'); | |
| on = document.querySelector('input[name="orderID"]'); | |
| pt = document.querySelector('input[name="title"]');; | |
| } | |
| else { | |
| console.error('Dialog not found'); | |
| } | |
| if (dd.value == "" ) { | |
| if (cb.checked == true) cb.click(); | |
| } else { | |
| dd.value = obj.disputeDate; | |
| } | |
| sh = document.getElementById('parcel-add-shop'); | |
| for (var i = 0; i < sh.options.length; i++) { | |
| if (sh.options[i].text === obj.shop) { | |
| sh.selectedIndex = i; | |
| break; | |
| } | |
| } | |
| on.value = obj.orderNo; | |
| pt.focus(); | |
| }) | |
| .catch(err => { | |
| console.error('Failed to read clipboard contents: ', err); | |
| }); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment