This repository has been archived by the owner on Aug 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Merged
Homepage #33
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
8e933f7
Add Competitive_Gwent
Soreine 6bf9b32
Refactor tooltip code
Soreine 3078b52
Following mouse
Soreine af94df6
Keep card within viewport
Soreine f7a24cf
Added aliases
Soreine 2cbb61c
Add failing test for accentuated letters
Soreine 68e9781
Add back accents
Soreine ae0ba8d
Support accents
Soreine e19eb43
Fix error in Chrome
Soreine f8933fc
Merge branch 'follow-mouse' into aliases
Soreine 25d5b55
Support GwentDB (don't double tooltips)
Soreine 2798cb3
Cleanup
Soreine 9cdf17f
Wrote content for home page
Soreine f8699e1
Wrote content for home page
Soreine f4e3c71
Merge branch 'support-gwentdb' into homepage
Soreine e59f79e
Merge branch 'aliases' into homepage
Soreine a1ca3bf
Add frog and fix ADC
Soreine 466427c
Hyper Gwent logo using Sketch
Soreine 4f26338
Improve R
Soreine a4ab406
Fix kerning
Soreine d1231d3
Add colors :rainbow:
Soreine f0a09a9
Improving homepage style
Soreine 5456322
Add dandelion and geralt avatars
Soreine e7ff027
Fix walker to skip script and styles tags
Soreine 07e6bc8
Added emotes :p
Soreine 7c80984
Fix responsiveness
Soreine e0501b3
Another wordplay
Soreine 6d2f303
Dark theme
Soreine 921c61e
Grammar
Soreine f259b20
Add link to issues
Soreine 7e6c5c7
Style issues
Soreine 8d6c37f
Add gradient background
Soreine 3613bbe
Link to compose a message
Soreine 13904ee
Add favicon
Soreine cbcab1a
Remove border from logo
Soreine 6db7f90
Add back border, but better
Soreine fb7e87e
Adjust button colors
Soreine 1b89bef
Add warning for non Chrome users. Fix rem
Soreine b65a950
Fix rem
Soreine 70e3bb6
Remove list style
Soreine 0984e2a
Update manifest.json
Soreine 892b387
Limit extension to GwentDB decks
Soreine df54ea9
Fix manifest.json
Soreine b750b8e
Extend to GwentDB forums
Soreine 0ef638c
Merge branch 'master' into homepage
Soreine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
{ | ||
"manifest_version": 2, | ||
"author": "Soreine & Zhouzi", | ||
"homepage": "https://soreine.github.io/hyper-gwent", | ||
"name": "Hyper Gwent", | ||
"description": "Enrich pages containing GwentⓇ related content. Card names quick access, terms highlight and more!", | ||
"description": "Show tooltips for cards in pages containing GwentⓇ related content.", | ||
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. Not sure if that's an issue but this description is different than the one on the website. |
||
"version": "0.1.0", | ||
"manifest_version": 2, | ||
"icons": { | ||
"16": "icon16.png", | ||
"48": "icon48.png", | ||
"128": "icon128.png" | ||
"16": "favicon16x16.png", | ||
"48": "favicon48x48.png", | ||
"128": "favicon128x128.png" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"https://www.reddit.com/r/gwent/*", | ||
"https://www.reddit.com/r/Competitive_Gwent/*", | ||
"http://www.gwentdb.com/*" | ||
"http://www.gwentdb.com/decks/*", | ||
"http://www.gwentdb.com/forums/*" | ||
], | ||
"js": [ | ||
"dist/content.js" | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,3 @@ | ||
/* global window, document */ | ||
import walk from './walk'; | ||
|
||
import urlParse from 'url-parse'; | ||
import findAllMatches from '../core/findAllMatches'; | ||
import replaceMatches from '../core/replaceMatches'; | ||
import tooltip from '../core/tooltip/index'; | ||
import { CARDS } from '../core/data'; | ||
import DICTIONARY from '../core/dictionary'; | ||
|
||
const CLASSNAME = 'hyper-gwent-card-highlight'; | ||
const CARD_NAME_ATTRIBUTE = 'data-card-name'; | ||
const GWENTDB_TOOLTIP_ATTR = 'data-tooltip-url'; | ||
const GWENTDB_HOSTNAME = 'www.gwentdb.com'; | ||
|
||
const HOSTNAME = urlParse(window.location.href).hostname; | ||
|
||
const walker = window.document.createTreeWalker( | ||
window.document.body, | ||
window.NodeFilter.SHOW_ELEMENT + window.NodeFilter.SHOW_TEXT, | ||
// Filter out GwentDB tooltips | ||
{ | ||
acceptNode(node) { | ||
const TEXT_NODE = 3; | ||
const ELEMENT_NODE = 1; | ||
|
||
const { | ||
FILTER_ACCEPT, | ||
FILTER_REJECT, | ||
FILTER_SKIP, | ||
} = window.NodeFilter; | ||
|
||
// Non GwentDB | ||
if (HOSTNAME !== GWENTDB_HOSTNAME) { | ||
return node.nodeType === TEXT_NODE | ||
? FILTER_ACCEPT | ||
: FILTER_SKIP; | ||
} | ||
|
||
// on GwentDB, we skip existing tooltips | ||
if ( | ||
node.nodeType === ELEMENT_NODE | ||
&& node.getAttribute(GWENTDB_TOOLTIP_ATTR) | ||
) { | ||
// Skip this node and all its children | ||
return FILTER_REJECT; | ||
} else if (node.nodeType === TEXT_NODE) { | ||
return FILTER_ACCEPT; | ||
} | ||
return FILTER_SKIP; | ||
}, | ||
}, | ||
); | ||
const nodes = []; | ||
|
||
while (walker.nextNode()) { | ||
const node = walker.currentNode; | ||
const matches = findAllMatches(DICTIONARY, node.nodeValue); | ||
|
||
if (matches.length) { | ||
nodes.push({ | ||
node, | ||
matches, | ||
}); | ||
} | ||
} | ||
|
||
nodes.forEach(({ node, matches }) => { | ||
const span = window.document.createElement('span'); | ||
span.innerHTML = replaceMatches(node.nodeValue, matches, match => `<span class="${CLASSNAME}" ${CARD_NAME_ATTRIBUTE}="${match.entryValue}" style="border-bottom: 1px dashed; padding-bottom: 0.1em">${node.nodeValue.slice(match.start, match.end)}</span>`); | ||
|
||
node.parentNode.replaceChild(span, node); | ||
}); | ||
|
||
// Add tooltips | ||
const highlights = document.getElementsByClassName(CLASSNAME); | ||
for (let i = 0; i < highlights.length; i += 1) { | ||
const highlight = highlights[i]; | ||
const cardName = highlight.getAttribute(CARD_NAME_ATTRIBUTE); | ||
const card = CARDS[cardName]; | ||
tooltip(card, highlight); | ||
} | ||
walk(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* global window, document */ | ||
|
||
import urlParse from 'url-parse'; | ||
import findAllMatches from '../core/findAllMatches'; | ||
import replaceMatches from '../core/replaceMatches'; | ||
import tooltip from '../core/tooltip/index'; | ||
import { CARDS } from '../core/data'; | ||
import DICTIONARY from '../core/dictionary'; | ||
|
||
const CLASSNAME = 'hyper-gwent-card-highlight'; | ||
const CARD_NAME_ATTRIBUTE = 'data-card-name'; | ||
const GWENTDB_TOOLTIP_ATTR = 'data-tooltip-url'; | ||
const GWENTDB_HOSTNAME = 'www.gwentdb.com'; | ||
|
||
// Walk the document and highlight cards | ||
function walk() { | ||
const HOSTNAME = urlParse(window.location.href).hostname; | ||
|
||
const walker = window.document.createTreeWalker( | ||
window.document.body, | ||
window.NodeFilter.SHOW_ELEMENT + window.NodeFilter.SHOW_TEXT, | ||
// Filter out GwentDB tooltips | ||
{ | ||
acceptNode(node) { | ||
const TEXT_NODE = 3; | ||
const ELEMENT_NODE = 1; | ||
|
||
const { | ||
FILTER_ACCEPT, | ||
FILTER_REJECT, | ||
FILTER_SKIP, | ||
} = window.NodeFilter; | ||
|
||
if (node.nodeType === TEXT_NODE) { | ||
return FILTER_ACCEPT; | ||
} else if ( | ||
node.nodeType === ELEMENT_NODE | ||
) { | ||
// Ignore style and scripts | ||
if (node.tagName === 'STYLE' | ||
|| node.tagName === 'SCRIPT') { | ||
return FILTER_REJECT; | ||
} | ||
|
||
// on GwentDB, we skip existing tooltips | ||
if (HOSTNAME === GWENTDB_HOSTNAME | ||
&& node.getAttribute(GWENTDB_TOOLTIP_ATTR)) { | ||
// Skip this node and all its children | ||
return FILTER_REJECT; | ||
} | ||
|
||
// Skip the node itself | ||
return FILTER_SKIP; | ||
} | ||
return FILTER_SKIP; | ||
}, | ||
}, | ||
); | ||
|
||
const nodes = []; | ||
|
||
while (walker.nextNode()) { | ||
const node = walker.currentNode; | ||
const matches = findAllMatches(DICTIONARY, node.nodeValue); | ||
|
||
if (matches.length) { | ||
nodes.push({ | ||
node, | ||
matches, | ||
}); | ||
} | ||
} | ||
|
||
nodes.forEach(({ node, matches }) => { | ||
const span = window.document.createElement('span'); | ||
span.innerHTML = replaceMatches(node.nodeValue, matches, match => `<span class="${CLASSNAME}" ${CARD_NAME_ATTRIBUTE}="${match.entryValue}" style="border-bottom: 1px dashed; padding-bottom: 0.1em">${node.nodeValue.slice(match.start, match.end)}</span>`); | ||
|
||
node.parentNode.replaceChild(span, node); | ||
}); | ||
|
||
// Add tooltips | ||
const highlights = document.getElementsByClassName(CLASSNAME); | ||
for (let i = 0; i < highlights.length; i += 1) { | ||
const highlight = highlights[i]; | ||
const cardName = highlight.getAttribute(CARD_NAME_ATTRIBUTE); | ||
const card = CARDS[cardName]; | ||
tooltip(card, highlight); | ||
} | ||
} | ||
|
||
export default walk; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,31 +2,95 @@ | |
|
||
// eslint-disable-next-line no-unused-vars | ||
import { createElement } from 'jsx-dom'; | ||
import tooltip from '../core/tooltip/index'; | ||
import walk from '../extension/walk'; | ||
import Logo from './logo.svg'; | ||
import style from './website.css'; | ||
|
||
const target = <span id="target" style="color: blue;">Aeromancy</span>; | ||
const app = ( | ||
const REDDIT = 'https://www.reddit.com/r/gwent/'; | ||
const GWENTDB = 'http://www.gwentdb.com/'; | ||
const REPO = 'https://github.com/Soreine/hyper-gwent/issues'; | ||
const EXT_LINK = '#'; | ||
|
||
const notUsingChrome = !window.chrome; | ||
|
||
const htmlPage = ( | ||
/* eslint-disable max-len */ | ||
<div> | ||
<p>C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.</p> | ||
<p>Any fool can write code that a computer can understand. Good programmers write code that humans can understand.</p> | ||
<p>This paragraph contains a card named {target}.</p> | ||
<p>It's not a bug - it's an undocumented feature.</p> | ||
<p>A good programmer is someone who always looks both ways before crossing a one-way street.</p> | ||
<p>The perfect project plan is possible if one first documents a list of all the unknowns.</p> | ||
<div className="content"> | ||
<style type="text/css">{style.toString()}</style> | ||
|
||
<div className="logo"> | ||
<div className="logo-title" | ||
innerHTML={Logo} /> | ||
<div className="logo-subtitle">{'Chrome extension for GWENT®: The Witcher Card Game'}</div> | ||
</div> | ||
|
||
<a className="download-link" href={EXT_LINK}>{'Add to Chrome'}</a> | ||
|
||
{notUsingChrome && <p className="nochrome"> | ||
This extension is only available for Chrome. The demonstration on this page will not work in other browsers. | ||
</p>} | ||
|
||
<div className="description"> | ||
<p> | ||
{'None of us can reasonably remember every possible Gwent card\'s name and effect. Browsing '} | ||
<a href={REDDIT}>{'/r/gwent'}</a> | ||
{' and reading deck guides on '} | ||
<a href={GWENTDB}>{'GwentDB'}</a> | ||
{' can be challenging if you don\'t know half the cards people are talking about.'} | ||
</p> | ||
|
||
<p> | ||
<em>{'You might find this shocking:'}</em> | ||
<ul> | ||
<li>{'Xmen are not what they used to be.'}</li> | ||
<li>{'ADC does not stand for Attack Damage Carry.'}</li> | ||
<li>{'There '}<em>{'are'}</em>{' worst names for a dragon than Borkh.'}</li> | ||
<li>{'Gwent has nothing to do with cooking frogs, mushrooms, or anything remotely related to french cuisine.'}</li> | ||
</ul> | ||
</p> | ||
|
||
<div className="emote"> | ||
<div className="avatar geralt"></div> | ||
<div className="emote-text"> | ||
{'Not bad. Not bad at all.'} | ||
</div> | ||
</div> | ||
|
||
<p> | ||
{'Whether you are new to the game, or you want to keep up with the latest card changes, or you can\'t remember crap, Hyper Gwent is here to save the day. Hyper Gwent automatically detects card names or acronyms in the pages you visit, highlights them and shows a tooltip when hovering them.'} | ||
</p> | ||
|
||
<p> | ||
{'Feature list:'} | ||
<ul> | ||
<li>{'Up to date with all existing cards'}</li> | ||
<li>{'Support acronyms, plurals, lowercase, and missing accents'}</li> | ||
<li>{'Lightweight'}</li> | ||
</ul> | ||
</p> | ||
|
||
<p>{'What do you think of that, Dandelion?'}</p> | ||
|
||
<div className="emote"> | ||
<div className="avatar dandelion"></div> | ||
<div className="emote-text"> | ||
{'That… was actually rather impressive. Congratulations.'} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
<a className="download-link" href={EXT_LINK}>{'Add to Chrome'}</a> | ||
|
||
<p className="issues"> | ||
If you find bugs, if you want to submit new acronyms, request a feature, or contribute, post an issue <a href={REPO}>here</a>. | ||
<br/> | ||
You can also contact <a href="https://www.reddit.com/message/compose/?to=Soreine">/u/Soreine</a>.</p> | ||
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. We could customize the HTML template to include all this, it'd be better for SEO & all. The Webpack loader would just insert the JavaScript specific code. |
||
</div> | ||
/* eslint-enable max-len */ | ||
); | ||
window.document.body.appendChild(app); | ||
|
||
tooltip({ | ||
name: 'Aeromancy', | ||
info: 'Play a Bronze or Silver Weather card from your Deck or Graveyard. Shuffle the others from your Deck back.', | ||
variations: [ | ||
{ | ||
art: { | ||
thumbnailImage: 'https://api.gwentapi.com/media/aeromancy-thumbnail.png', | ||
}, | ||
}, | ||
], | ||
}, target); | ||
window.document.body.appendChild(htmlPage); | ||
|
||
|
||
// Launch extension within the page | ||
walk(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❤️