From 8ee7845d90dfa5fc3a355246750e022db236cd55 Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Mon, 15 Feb 2016 23:55:31 +0000 Subject: [PATCH 1/7] added fixes panel --- inline/gameboard.js | 28 ++++++++++++++++++++++++++++ inline/jankteki.css | 8 ++++++++ inline/lobby.js | 2 +- manifest.json | 4 ++-- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 inline/gameboard.js diff --git a/inline/gameboard.js b/inline/gameboard.js new file mode 100644 index 0000000..baf2df2 --- /dev/null +++ b/inline/gameboard.js @@ -0,0 +1,28 @@ +// put command panel in middle panel + + +var observer = new MutationObserver(function () { + if (document.querySelector('#gameboard').style.display !== "none") { + createFixesPanel(); + } +}); + +var gameBoard = document.querySelector('#gameboard'); +observer.observe(gameBoard, {childList: true}); + +// use websockets to post commands: socket = io.connect(iourl + '/lobby') +// to post chat: socket.emit("netrunner", {"action":"do","gameid":localStorage['gameid'],"command":"say","args":{"user":user,"text":"deck 3"}}) + +function createFixesPanel() { + if (!document.getElementById('fixes-pane')) { + var fixes = document.createElement('div'); + + fixes.id = 'fixes-pane'; + fixes.innerHTML = '

Fixes

'; + + var secondaryPane = document.querySelector('.secondary-pane'), + buttonPane = document.querySelector('.button-pane'); + + secondaryPane.insertBefore(fixes, buttonPane); + } +} diff --git a/inline/jankteki.css b/inline/jankteki.css index 842351e..c523a76 100644 --- a/inline/jankteki.css +++ b/inline/jankteki.css @@ -21,3 +21,11 @@ .friends-title { margin-top: 10px; } + +#gameboard .gameboard .secondary-pane { + justify-content: flex-end; +} + +.gameboard .secondary-pane > div { + margin-top: 5px; +} diff --git a/inline/lobby.js b/inline/lobby.js index 6b72215..2dc2b81 100644 --- a/inline/lobby.js +++ b/inline/lobby.js @@ -1,6 +1,6 @@ var friends = []; -var observer = new MutationObserver(function() { +var observer = new MutationObserver(function () { if (document.querySelector('#gamelobby').style.display !== "none") { chrome.storage.sync.get(['friends'], function (items) { var pinned = getOrCreatePinned(); diff --git a/manifest.json b/manifest.json index 523c275..2236a4d 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Jankteki", "description": "An enhancement suite for jinteki.net", - "version": "0.3.0", + "version": "0.4.0", "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", @@ -27,7 +27,7 @@ "matches": [ "http://www.jinteki.net/*" ], - "js": ["inline/lobby.js"], + "js": ["inline/lobby.js", "inline/gameboard.js"], "css": ["inline/jankteki.css"], "run_at": "document_end" } From 810c68bf353ef7b66ae85464a483e9539b188efc Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Tue, 16 Feb 2016 19:02:36 +0000 Subject: [PATCH 2/7] added button. Currently just echoes. --- inline/gameboard.js | 27 ++++++++++++++++++++++----- inline/injector.js | 6 ++++++ inline/jankteki.css | 12 ++++++++++++ manifest.json | 4 ++-- 4 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 inline/injector.js diff --git a/inline/gameboard.js b/inline/gameboard.js index baf2df2..045a876 100644 --- a/inline/gameboard.js +++ b/inline/gameboard.js @@ -1,18 +1,35 @@ -// put command panel in middle panel - +var socket = io.connect(iourl + '/lobby'); var observer = new MutationObserver(function () { if (document.querySelector('#gameboard').style.display !== "none") { createFixesPanel(); + + var fixesPanel = document.querySelector('#fixes-pane .panel'), + closeBtn = document.createElement('button'); + + closeBtn.innerHTML = 'Close Prompt'; + + fixesPanel.appendChild(closeBtn); + + closeBtn.addEventListener('click', function () { + socket.emit("netrunner", { + "action": "do", + "gameid": localStorage['gameid'], + "command": "say", + "args": { + "user": user, "text": "Close Prompt" + } + }); + }); + + // close button: close-prompt + // send command /close-prompt } }); var gameBoard = document.querySelector('#gameboard'); observer.observe(gameBoard, {childList: true}); -// use websockets to post commands: socket = io.connect(iourl + '/lobby') -// to post chat: socket.emit("netrunner", {"action":"do","gameid":localStorage['gameid'],"command":"say","args":{"user":user,"text":"deck 3"}}) - function createFixesPanel() { if (!document.getElementById('fixes-pane')) { var fixes = document.createElement('div'); diff --git a/inline/injector.js b/inline/injector.js new file mode 100644 index 0000000..d874421 --- /dev/null +++ b/inline/injector.js @@ -0,0 +1,6 @@ +var s = document.createElement('script'); +s.src = chrome.extension.getURL('inline/gameboard.js'); +s.onload = function() { + this.parentNode.removeChild(this); +}; +(document.head || document.documentElement).appendChild(s); \ No newline at end of file diff --git a/inline/jankteki.css b/inline/jankteki.css index c523a76..3e2b1eb 100644 --- a/inline/jankteki.css +++ b/inline/jankteki.css @@ -29,3 +29,15 @@ .gameboard .secondary-pane > div { margin-top: 5px; } + +.gameboard #fixes-pane h4 { + margin-bottom: 10px; + text-align: center; +} + +.gameboard #fixes-pane button { + width: 100%; + font-size: 11px; + margin: 0 0 5px 0; + padding: 0 8px 1px; +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 2236a4d..90e0bde 100644 --- a/manifest.json +++ b/manifest.json @@ -27,12 +27,12 @@ "matches": [ "http://www.jinteki.net/*" ], - "js": ["inline/lobby.js", "inline/gameboard.js"], + "js": ["inline/lobby.js", "inline/injector.js"], "css": ["inline/jankteki.css"], "run_at": "document_end" } ], - + "web_accessible_resources": ["inline/gameboard.js"], "permissions": [ "contextMenus", "declarativeContent", From b87acdc309cb758067b521a9124dba806d8bd1af Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Tue, 16 Feb 2016 23:54:17 +0000 Subject: [PATCH 3/7] working /close-prompt --- inline/gameboard.js | 45 +++++++++++++++++++++++++++------------------ inline/jankteki.css | 2 +- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/inline/gameboard.js b/inline/gameboard.js index 045a876..b434ea0 100644 --- a/inline/gameboard.js +++ b/inline/gameboard.js @@ -5,32 +5,16 @@ var observer = new MutationObserver(function () { createFixesPanel(); var fixesPanel = document.querySelector('#fixes-pane .panel'), - closeBtn = document.createElement('button'); - - closeBtn.innerHTML = 'Close Prompt'; + closeBtn = createCloseButton(); fixesPanel.appendChild(closeBtn); - - closeBtn.addEventListener('click', function () { - socket.emit("netrunner", { - "action": "do", - "gameid": localStorage['gameid'], - "command": "say", - "args": { - "user": user, "text": "Close Prompt" - } - }); - }); - - // close button: close-prompt - // send command /close-prompt } }); var gameBoard = document.querySelector('#gameboard'); observer.observe(gameBoard, {childList: true}); -function createFixesPanel() { +function createFixesPanel () { if (!document.getElementById('fixes-pane')) { var fixes = document.createElement('div'); @@ -43,3 +27,28 @@ function createFixesPanel() { secondaryPane.insertBefore(fixes, buttonPane); } } + +function createCloseButton () { + var button = document.createElement('button'); + + button.innerHTML = 'Close Prompt'; + + button.addEventListener('click', function () { + socket.emit("netrunner", { + "action": "do", + "gameid": localStorage['gameid'], + "command": "say", + "side": getSide(), + "args": { + "user": user, + "text": "/close-prompt" + } + }); + }); + + return button; +} + +function getSide () { + return document.querySelector('.runner-board.opponent') ? 'corp' : 'runner'; +} diff --git a/inline/jankteki.css b/inline/jankteki.css index 3e2b1eb..5ec6bb4 100644 --- a/inline/jankteki.css +++ b/inline/jankteki.css @@ -40,4 +40,4 @@ font-size: 11px; margin: 0 0 5px 0; padding: 0 8px 1px; -} \ No newline at end of file +} From 80c853589442c0bb6c7181ee84fe3a833c611ebf Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Wed, 17 Feb 2016 01:03:16 +0000 Subject: [PATCH 4/7] added all of the fix buttons --- inline/gameboard.js | 42 ++++++++++++++++++++++++++++++++++++------ inline/jankteki.css | 13 +++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/inline/gameboard.js b/inline/gameboard.js index b434ea0..64dc381 100644 --- a/inline/gameboard.js +++ b/inline/gameboard.js @@ -4,10 +4,35 @@ var observer = new MutationObserver(function () { if (document.querySelector('#gameboard').style.display !== "none") { createFixesPanel(); - var fixesPanel = document.querySelector('#fixes-pane .panel'), - closeBtn = createCloseButton(); + var fixesPanel = document.querySelector('#fixes-pane .panel'); - fixesPanel.appendChild(closeBtn); + var buttons = [ + {text: 'Draw n cards', command: 'draw', prompt: 'How many to draw?'}, + {text: 'Adjust credits', command: 'credit', prompt: 'How many credits?'}, + {text: 'Adjust clicks', command: 'click', prompt: 'How many clicks?'}, + {text: 'Adjust memory', command: 'memory', prompt: 'How much memory?', side: 'runner'}, + {text: 'Adjust tags', command: 'tag', prompt: 'How many tags?', side: 'runner'}, + {text: 'Adjust bad publicity', command: 'bp', prompt: 'How much bad publicity?', side: 'corp'}, + {text: 'Adjust link', command: 'link', prompt: 'How much link?', side: 'runner'}, + {text: 'Adjust hand size', command: 'handsize', prompt: 'What is your handsize?'}, + {text: 'Take meat damage', command: 'take-meat', prompt: 'How much meat damage?', side: 'runner'}, + {text: 'Take net damage', command: 'take-net', prompt: 'How much net damage?', side: 'runner'}, + {text: 'Take brain damage', command: 'take-brain', prompt: 'How much brain damage?', side: 'runner'}, + {text: 'Discard card', command: 'discard', prompt: 'Which card?', which: true}, + {text: 'Put card on deck', command: 'deck', prompt: 'Which card?', which: true}, + {text: 'Initiate trace', command: 'trace', prompt: 'Base strength?', side: 'corp'}, + {text: 'Close active prompt', command: 'close-prompt'}, + {text: 'Start a Psi game', command: 'psi', 'side': 'corp'}, + {text: 'End a run', command: 'end-run', 'side': 'corp'}, + {text: 'Jack out', command: 'jack-out', 'side': 'runner'}, + {text: 'Set card counters', command: 'counter', 'prompt': 'How many counters?'}, + {text: 'Advance card', command: 'adv-counter', 'prompt': 'How many counters?', side: 'corp'}, + {text: 'Debug card', command: 'card-info'} + ]; + + buttons.forEach((btn) => fixesPanel.appendChild( + createFixButton(btn) + )); } }); @@ -18,6 +43,7 @@ function createFixesPanel () { if (!document.getElementById('fixes-pane')) { var fixes = document.createElement('div'); + fixes.className = getSide(); fixes.id = 'fixes-pane'; fixes.innerHTML = '

Fixes

'; @@ -28,12 +54,16 @@ function createFixesPanel () { } } -function createCloseButton () { +function createFixButton (btn) { var button = document.createElement('button'); - button.innerHTML = 'Close Prompt'; + button.innerHTML = btn.text; + button.className = 'side' in btn ? btn.side : ''; button.addEventListener('click', function () { + var n = btn.prompt ? prompt(btn.prompt) : ''; + n = btn.which ? ' #' + n : ' ' + n; + socket.emit("netrunner", { "action": "do", "gameid": localStorage['gameid'], @@ -41,7 +71,7 @@ function createCloseButton () { "side": getSide(), "args": { "user": user, - "text": "/close-prompt" + "text": "/" + btn.command + n } }); }); diff --git a/inline/jankteki.css b/inline/jankteki.css index 5ec6bb4..e4f5bdf 100644 --- a/inline/jankteki.css +++ b/inline/jankteki.css @@ -30,6 +30,11 @@ margin-top: 5px; } +.gameboard #fixes-pane .panel { + max-height: 200px; + overflow: scroll; +} + .gameboard #fixes-pane h4 { margin-bottom: 10px; text-align: center; @@ -41,3 +46,11 @@ margin: 0 0 5px 0; padding: 0 8px 1px; } + +#fixes-pane.corp button.runner { + display: none; +} + +#fixes-pane.runner button.corp { + display: none; +} From 51d77d2676a579ca27030b40146f9987c45fcfff Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Fri, 19 Feb 2016 01:57:16 +0000 Subject: [PATCH 5/7] styled fix panel, made expandable --- inline/gameboard.js | 15 ++++++++++++++- inline/injector.js | 2 +- inline/jankteki.css | 30 ++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/inline/gameboard.js b/inline/gameboard.js index 64dc381..72dd89e 100644 --- a/inline/gameboard.js +++ b/inline/gameboard.js @@ -50,7 +50,20 @@ function createFixesPanel () { var secondaryPane = document.querySelector('.secondary-pane'), buttonPane = document.querySelector('.button-pane'); - secondaryPane.insertBefore(fixes, buttonPane); + var buttonWrap = document.createElement('div'); + buttonWrap.id = 'button-wrap'; + + buttonWrap.appendChild(fixes); + + buttonWrap.insertBefore(buttonPane, fixes); + + secondaryPane.appendChild(buttonWrap); + + var expander = document.querySelector('#fixes-pane h4'); + var panel = document.querySelector('#fixes-pane .panel'); + + expander.addEventListener('click', + () => panel.classList.toggle('expanded')); } } diff --git a/inline/injector.js b/inline/injector.js index d874421..939f7bd 100644 --- a/inline/injector.js +++ b/inline/injector.js @@ -3,4 +3,4 @@ s.src = chrome.extension.getURL('inline/gameboard.js'); s.onload = function() { this.parentNode.removeChild(this); }; -(document.head || document.documentElement).appendChild(s); \ No newline at end of file +(document.head || document.documentElement).appendChild(s); diff --git a/inline/jankteki.css b/inline/jankteki.css index e4f5bdf..18253aa 100644 --- a/inline/jankteki.css +++ b/inline/jankteki.css @@ -22,16 +22,11 @@ margin-top: 10px; } -#gameboard .gameboard .secondary-pane { - justify-content: flex-end; -} - .gameboard .secondary-pane > div { margin-top: 5px; } .gameboard #fixes-pane .panel { - max-height: 200px; overflow: scroll; } @@ -41,10 +36,33 @@ } .gameboard #fixes-pane button { - width: 100%; font-size: 11px; margin: 0 0 5px 0; padding: 0 8px 1px; + width: 100%; +} + +#fixes-pane .panel { + height: 28px; + margin-top: 5px; + transition: height 0.8s; +} + +#fixes-pane .panel.expanded { + height: 150px; +} + +#fixes-pane .panel h4 { + cursor: pointer; +} + +#fixes-pane .panel h4 span::before { + color: #fff; + content: "▸ "; +} + +#fixes-pane .panel.expanded h4 span::before { + content: "▾ "; } #fixes-pane.corp button.runner { From 32d912b9b633f5e4d0df6505e46b1e370c825a7e Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Fri, 19 Feb 2016 02:00:19 +0000 Subject: [PATCH 6/7] redundant css --- inline/jankteki.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/inline/jankteki.css b/inline/jankteki.css index 18253aa..6cc7348 100644 --- a/inline/jankteki.css +++ b/inline/jankteki.css @@ -22,10 +22,6 @@ margin-top: 10px; } -.gameboard .secondary-pane > div { - margin-top: 5px; -} - .gameboard #fixes-pane .panel { overflow: scroll; } From e27ca4b5235a5124c6845cc059ff370ec456cea1 Mon Sep 17 00:00:00 2001 From: Simon Scarfe Date: Fri, 19 Feb 2016 02:04:17 +0000 Subject: [PATCH 7/7] updated README for fixes panel --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c93839..556fff8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -I hope one day this will be a useful jinteki.net extension. +This is an extension for the jinteki.net website. -Currently it maintains a list of friends (or cyber-celebrities ;-) ) online and pins links to their running games to the top of the screen. +Features: -Once I've got a couple of dummy icons, and made it look less crap, I shall be releasing this in the Chrome App Store. +* maintains a list of friends (or cyber-celebrities ;-) ) online +* pins links to friends games in progress to the top of the lobby. +* introduces a fixes panel in-game. This panel serves as a series of shortcuts for the jinteki.net [commands list](http://www.jinteki.net/help#commands). [Trello Board for Janteki](https://trello.com/b/sJSYgy2m/jankteki)