Compare commits
2 Commits
d8fad1df84
...
9d1c98dd98
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d1c98dd98 | |||
| 5f4482e8d3 |
17
.eslintrc.js
Normal file
17
.eslintrc.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"globals": {
|
||||||
|
"Atomics": "readonly",
|
||||||
|
"SharedArrayBuffer": "readonly"
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2018,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
};
|
||||||
91
.gitignore
vendored
Normal file
91
.gitignore
vendored
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/tmp
|
||||||
|
/out-tsc
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.sass-cache
|
||||||
|
connect.lock
|
||||||
|
typings
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Lerna
|
||||||
|
lerna-debug.log
|
||||||
|
|
||||||
|
# System Files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
@@ -2,57 +2,61 @@
|
|||||||
// @name Bazaar Helper
|
// @name Bazaar Helper
|
||||||
// @namespace https://jotde.eu
|
// @namespace https://jotde.eu
|
||||||
// @updateURL https://gitea.jotde.be/jens/tornjs/raw/branch/master/bazaar.user.js
|
// @updateURL https://gitea.jotde.be/jens/tornjs/raw/branch/master/bazaar.user.js
|
||||||
// @version 0.1
|
// @version 0.2
|
||||||
// @description try to take over the world!
|
// @description try to take over the world!
|
||||||
// @author JotDe:
|
// @author JotDe:
|
||||||
// @match https://www.torn.com/bazaar.php*
|
// @match https://www.torn.com/bazaar.php*
|
||||||
// @grant GM.xmlHttpRequest
|
// @grant GM.xmlHttpRequest
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|
||||||
const callMarketApi = new Promise((resolve, reject) => {
|
const callMarketApi = new Promise((resolve, reject) => {
|
||||||
GM.xmlHttpRequest({
|
GM.xmlHttpRequest({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "http://jotde.eu/api/market",
|
url: "http://jotde.eu/api/market",
|
||||||
onload: function(response) {
|
onload: function (response) {
|
||||||
if (response.status != 200) {
|
if (response.status != 200) {
|
||||||
reject(`HTTP Status ${response.status} ${response.statusText}: ${response.responseText}`);
|
reject(
|
||||||
}
|
`HTTP Status ${response.status} ${response.statusText}: ${response.responseText}`
|
||||||
resolve(JSON.parse(response.responseText));
|
);
|
||||||
}
|
}
|
||||||
});
|
resolve(JSON.parse(response.responseText));
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
async function forElement(element) {
|
async function forElement(element) {
|
||||||
while (!document.querySelector(element)) {
|
while (!document.querySelector(element)) {
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changePlaceholder(marketItems) {
|
async function changePlaceholder(marketItems) {
|
||||||
|
let itemList = document.querySelectorAll('ul[class^="items-cont"][style="display:block;"] li');
|
||||||
|
console.log(marketItems);
|
||||||
|
itemList.forEach((item) => {
|
||||||
|
const itemid = item.querySelector("img").getAttribute("src").split("/")[3];
|
||||||
|
const marketItem = marketItems[itemid];
|
||||||
|
|
||||||
let itemList = document.querySelectorAll(selectedBazaarTab + " li");
|
if (marketItem) {
|
||||||
console.log(marketItems);
|
item
|
||||||
itemList.forEach(item => {
|
.querySelector('div[class="amount"] input[type="text"]')
|
||||||
itemid = item.querySelector('img').getAttribute('src').split('/')[3];
|
.setAttribute("placeholder", marketItem["count"]);
|
||||||
|
item
|
||||||
marketItem = marketItems[itemid];
|
.querySelector(
|
||||||
if(marketItem){
|
'div[class="price"] div[class^="input-money-group"] input[type="text"]'
|
||||||
item.querySelector('div[class="amount"] input[type="text"]').setAttribute('placeholder', marketItem['count']);
|
)
|
||||||
item.querySelector('div[class="price"] div[class^="input-money-group"] input[type="text"]').setAttribute('placeholder', marketItem['avg']);
|
.setAttribute("placeholder", marketItem["avg"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeErrorOnConsole(error) {
|
async function writeErrorOnConsole(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
selectedBazaarTab = 'ul[class^="items-cont"][style="display:block;"]';
|
await forElement('ul[class^="items-cont"][style="display:block;"]');
|
||||||
await forElement(selectedBazaarTab);
|
callMarketApi.then(changePlaceholder, writeErrorOnConsole);
|
||||||
callMarketApi.then(changePlaceholder, writeErrorOnConsole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|||||||
11
jsconfig.json
Normal file
11
jsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es2016",
|
||||||
|
"jsx": "preserve"
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"**/node_modules/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
1657
package-lock.json
generated
Normal file
1657
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
package.json
Normal file
22
package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "tornjs",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Torn Userscripts by JotDe:",
|
||||||
|
"main": "bazaar.user.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "jotde@gitea.jotde.be:jens/tornjs.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"torn",
|
||||||
|
"userscript",
|
||||||
|
"js",
|
||||||
|
"javascript",
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"author": "JotDe:",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user