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,45 +2,50 @@
|
||||
// @name Bazaar Helper
|
||||
// @namespace https://jotde.eu
|
||||
// @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!
|
||||
// @author JotDe:
|
||||
// @match https://www.torn.com/bazaar.php*
|
||||
// @grant GM.xmlHttpRequest
|
||||
// ==/UserScript==
|
||||
|
||||
|
||||
const callMarketApi = new Promise((resolve, reject) => {
|
||||
GM.xmlHttpRequest({
|
||||
method: "GET",
|
||||
url: "http://jotde.eu/api/market",
|
||||
onload: function (response) {
|
||||
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));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
async function forElement(element) {
|
||||
while (!document.querySelector(element)) {
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
}
|
||||
|
||||
async function changePlaceholder(marketItems) {
|
||||
|
||||
let itemList = document.querySelectorAll(selectedBazaarTab + " li");
|
||||
let itemList = document.querySelectorAll('ul[class^="items-cont"][style="display:block;"] li');
|
||||
console.log(marketItems);
|
||||
itemList.forEach(item => {
|
||||
itemid = item.querySelector('img').getAttribute('src').split('/')[3];
|
||||
itemList.forEach((item) => {
|
||||
const itemid = item.querySelector("img").getAttribute("src").split("/")[3];
|
||||
const marketItem = marketItems[itemid];
|
||||
|
||||
marketItem = marketItems[itemid];
|
||||
if (marketItem) {
|
||||
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']);
|
||||
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"]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -50,8 +55,7 @@ async function writeErrorOnConsole(error) {
|
||||
}
|
||||
|
||||
async function run() {
|
||||
selectedBazaarTab = 'ul[class^="items-cont"][style="display:block;"]';
|
||||
await forElement(selectedBazaarTab);
|
||||
await forElement('ul[class^="items-cont"][style="display:block;"]');
|
||||
callMarketApi.then(changePlaceholder, writeErrorOnConsole);
|
||||
}
|
||||
|
||||
|
||||
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