Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: 1 2 3 [4] 5 6 ... 9  All

Author Topic: Chrome Extension for f.ds!  (Read 113869 times)

0 Members and 1 Guest are viewing this topic.

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #75 on: June 08, 2016, 11:30:09 pm »
+1

It works! Version 1.11 is done; should auto-updated within the next day. Aside from the rest of the Empires icons and cards; this improves the way that inserting costs and icons works. No more does it stick a big ugly URL in; instead it just inserts markup which is auto-replaced. This means you can also just type the markup. Coin costs are in the form [] with a $ and a number inside. Debt is the same except with <> instead of []. You can just click a button or just hover over it to see the proper markup.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

werothegreat

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 8172
  • Shuffle iT Username: werothegreat
  • Let me tell you a secret...
  • Respect: +9625
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #76 on: June 08, 2016, 11:47:18 pm »
+1

I'm getting a hover image for Wild Hunt, but not Salt the Earth.
Logged
Contrary to popular belief, I do not run the wiki all on my own.  There are plenty of other people who are actively editing.  Go bother them!

Check out this fantasy epic adventure novel I wrote, the Broken Globe!  http://www.amazon.com/Broken-Globe-Tyr-Chronicles-Book-ebook/dp/B00LR1SZAS/

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #77 on: June 08, 2016, 11:56:51 pm »
0

I'm getting a hover image for Wild Hunt, but not Salt the Earth.

That's fixed in 1.11; 1.10 isn't showing the image. It's because Salt the Earth is the first event to have more than 2 words in the name. Turns out that I was only replacing spaces with underscores for the first space... which as it turns out is fine as far as the wiki is concerned; it works fine with spaces or underscores in the card names. But it was breaking the landscape code; so I found and fixed it; so that now it properly uses underscores in the card name when posting. So because I posted those links with 1.11; they have underscores. But 1.10 is incorrectly expecting 1 underscore and 1 space..
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #78 on: June 09, 2016, 12:00:11 am »
0

Still digging around trying to figure out Firefox addons. Found this: https://addons.mozilla.org/en-US/firefox/addon/dominion-full-card-display/?src=search. So awesome... I wonder if the guy who made that posts here?
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

Seprix

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5607
  • Respect: +3676
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #79 on: June 09, 2016, 12:18:51 am »
0

Still digging around trying to figure out Firefox addons. Found this: https://addons.mozilla.org/en-US/firefox/addon/dominion-full-card-display/?src=search. So awesome... I wonder if the guy who made that posts here?

He has jakebuck.net, apparently. I don't know if that exists or not, I cannot tell because of ISP blocking.
Logged
DM me for ideas on a new article, either here or on Discord (I check Discord way more often)

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #80 on: June 09, 2016, 12:31:56 am »
0

Still digging around trying to figure out Firefox addons. Found this: https://addons.mozilla.org/en-US/firefox/addon/dominion-full-card-display/?src=search. So awesome... I wonder if the guy who made that posts here?

He has jakebuck.net, apparently. I don't know if that exists or not, I cannot tell because of ISP blocking.

It's doesn't (anymore), but jakebuck.com does; I sent him a message through that.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

Seprix

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5607
  • Respect: +3676
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #81 on: June 09, 2016, 09:22:24 am »
0

Still digging around trying to figure out Firefox addons. Found this: https://addons.mozilla.org/en-US/firefox/addon/dominion-full-card-display/?src=search. So awesome... I wonder if the guy who made that posts here?

He has jakebuck.net, apparently. I don't know if that exists or not, I cannot tell because of ISP blocking.

It's doesn't (anymore), but jakebuck.com does; I sent him a message through that.

Yes, I can visit that site!!! Did you try that link randomly, by accident, or did you have some prior knowledge I did not in your Google Quest?
Logged
DM me for ideas on a new article, either here or on Discord (I check Discord way more often)

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #82 on: June 09, 2016, 10:42:36 am »
0

Still digging around trying to figure out Firefox addons. Found this: https://addons.mozilla.org/en-US/firefox/addon/dominion-full-card-display/?src=search. So awesome... I wonder if the guy who made that posts here?

He has jakebuck.net, apparently. I don't know if that exists or not, I cannot tell because of ISP blocking.

It's doesn't (anymore), but jakebuck.com does; I sent him a message through that.

Yes, I can visit that site!!! Did you try that link randomly, by accident, or did you have some prior knowledge I did not in your Google Quest?

I think I Googled "Jake Buck Dominion" or something.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

Seprix

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5607
  • Respect: +3676
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #83 on: June 09, 2016, 10:51:13 am »
+1

I think I Googled "Jake Buck Dominion" or something.

Hmm. I got too meta for my own good. I googled "Jake Buck forum.dominionstrategy" yesterday and found nothing. He hasn't posted anything since 2012, so it's likely he either died or got lazy/busy, and thus it is more likely than not that if he was a forum member on here, he would have not logged in since 2012. Good luck with your e-mail, you stalker. :)
« Last Edit: June 09, 2016, 10:53:46 am by Seprix »
Logged
DM me for ideas on a new article, either here or on Discord (I check Discord way more often)

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #84 on: June 15, 2016, 01:07:16 am »
+2

So I went to read the Secret History of Empires, but realized that it was problematic that it didn't have hover-links for the cards; considering that I don't know almost any of the card effects by name yet. So, I went about adding an "auto-link" feature, which would (optionally) add the hover-links to all card names used in a post, even if the person who posted it doesn't have the extension, or chose not to add the card link markup.

So I got basic functionality working fine; but cards that use the names of other cards turns out to be a bigger problem than I thought. I give the markup to City Quarter; it then becomes surprisingly hard to not mess it up as it tries to then give that same text the markup for City.

So, the solution is to take the easy way out, at least for now... cards that are a smaller part of other card names are simply excluded. City won't get the markup; City Quarter works fine. All the Villages work except Village, and sadly Villa. It doesn't affect very many Empires cards anyway; I think just Villa and Triumph. So enjoy reading the secret history with card links!

And in an effort to get this out before everyone has read the secret history anyway, only enabling the links works for now. Unchecking the box does nothing. Checking it again messes stuff up by adding in the links a second time. But refreshing the page always starts clean.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #85 on: June 15, 2016, 01:22:15 am »
0

2 more things:

1. It turns out doing the "unlink" thing is really easy; so you can now both check and uncheck the checkbox.

2. I don't recommend using it on any page that already has card links, it messes up. But it should be good on secret histories, or card rankings, etc.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

Seprix

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5607
  • Respect: +3676
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #86 on: June 15, 2016, 04:42:11 pm »
0

If someone is going on a camping trip and mentions that he is packing his gear, will it highlight?
Logged
DM me for ideas on a new article, either here or on Discord (I check Discord way more often)

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #87 on: June 15, 2016, 04:58:08 pm »
+1

If someone is going on a camping trip and mentions that he is packing his gear, will it highlight?

Actually no, because it's case sensitive, at least for now. This has the drawback that saying "I bought a grand market" won't highlight either. But other than the casing, yes.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

ThetaSigma12

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1681
  • Shuffle iT Username: ThetaSigma12
  • Respect: +1809
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #88 on: June 15, 2016, 05:56:14 pm »
+1

The extension is great! I wonder if you could have the thing check for spaces on the end, i.e " Villa " instead of "Villa". That would also fix the Count, Counting House problem, words like "Taxing", and words that might appear in images.
« Last Edit: June 15, 2016, 05:57:39 pm by ThetaSigma12 »
Logged
My magnum opus collection of dominion fan cards is available here!

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #89 on: June 15, 2016, 06:19:27 pm »
+1

The extension is great! I wonder if you could have the thing check for spaces on the end, i.e " Villa " instead of "Villa". That would also fix the Count, Counting House problem, words like "Taxing", and words that might appear in images.

Thanks!

I thought about that, but I was concerned about things like other tags, like bold fonts which are actually used in the secret histories. But I think I just need to up my regex game; I think word boundaries might actually handle non-letters correctly. I'll play with it some more; I got a couple other ideas for how to fix it for all card names.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

Deadlock39

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1722
  • Respect: +1757
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #90 on: June 15, 2016, 08:26:30 pm »
+1

I don't know if this works because of the JavaScript replace function, or if it is applicable here, but the replacement regex that the log prettifier uses captures all the card names by joining them with "|" (i.e. "Counting House|Count|Fishing Village|Village|Villa").  It sorts them by length so that the regex picks the longer words first and only falls to the shorter ones after.  It uses this regex to replace the card names with themselves wrapped with the appropriate css to display them with their card color.

The code looks like this:

Code: [Select]
var keys = Object.keys(colorClassDict); //This dictionary maps all the card names to their css class
var regExp = new RegExp( keys.sort(function(a,b){return b.length-a.length}).join('|'), 'g' );

function colorCards(str)
    {
    return str.replace(regExp, replace);
    }

function replace(key)
    {
    var value = colorClassDict[key];
    return '<p class="'+value+'">'+key+'</p>';
    }

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #91 on: June 15, 2016, 08:49:31 pm »
0

I don't know if this works because of the JavaScript replace function, or if it is applicable here, but the replacement regex that the log prettifier uses captures all the card names by joining them with "|" (i.e. "Counting House|Count|Fishing Village|Village|Villa").  It sorts them by length so that the regex picks the longer words first and only falls to the shorter ones after.  It uses this regex to replace the card names with themselves wrapped with the appropriate css to display them with their card color.

The code looks like this:

Code: [Select]
var keys = Object.keys(colorClassDict); //This dictionary maps all the card names to their css class
var regExp = new RegExp( keys.sort(function(a,b){return b.length-a.length}).join('|'), 'g' );

function colorCards(str)
    {
    return str.replace(regExp, replace);
    }

function replace(key)
    {
    var value = colorClassDict[key];
    return '<p class="'+value+'">'+key+'</p>';
    }

Thanks! I'm doing a similar thing actually with sorting the cards by longest first; but I was looping through all cards and doing the replacements for each one. Joining them all in a regex like that sounds like a good idea. But.. where is the "replace" coming from in the call to str.replace()? It would be the card name basically, but how do you extract the card name from the regex match?
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #92 on: June 15, 2016, 09:04:09 pm »
+1

I don't know if this works because of the JavaScript replace function, or if it is applicable here, but the replacement regex that the log prettifier uses captures all the card names by joining them with "|" (i.e. "Counting House|Count|Fishing Village|Village|Villa").  It sorts them by length so that the regex picks the longer words first and only falls to the shorter ones after.  It uses this regex to replace the card names with themselves wrapped with the appropriate css to display them with their card color.

The code looks like this:

Code: [Select]
var keys = Object.keys(colorClassDict); //This dictionary maps all the card names to their css class
var regExp = new RegExp( keys.sort(function(a,b){return b.length-a.length}).join('|'), 'g' );

function colorCards(str)
    {
    return str.replace(regExp, replace);
    }

function replace(key)
    {
    var value = colorClassDict[key];
    return '<p class="'+value+'">'+key+'</p>';
    }

Never mind that question, I got it with the str.replace that takes a regex and a function call. The function is passed in the word that matched, which in this case is the card name. Using that, I was able to do it perfectly in a few lines of code!

So right before I saw your post, I had just finished my other solution, which I spent the last couple of hours implementing... I had been looping through all text nodes on the page, and replacing them one at a time, as long as they weren't children of a link. It was super inefficient both in coding and runtime execution. Your suggestion is awesome; wish I'd thought of it before! I had thought of a giant regex that would incorporate all cards at once, but I didn't know how I could use that to replace each match with the right thing.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

Deadlock39

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1722
  • Respect: +1757
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #93 on: June 15, 2016, 09:07:48 pm »
+1

PPE: Awesome, glad it worked!  I'll post my comments below in case it is helpful to anyone looking through here at a later time.




Well, the replace is a reference to the function below the colorCards function.  The code I posted is hacked up a bit from code I have that I stole from the randomizer. It is part of a class, so I ripped out a few instances of "this."

I can't honestly say I understand it 100% since I stole it from the log prettifier, but here is my best attempt at an explaination:
With JS, if you call String.replace( <regex>, <function> ), it takes the match from the regex and passes it to the function. and then replaces the match with the value the function returns.  The 'g' in the regex makes it grab all the matches, so the regex itself prevents you from reparsing things that were already matched. 

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #94 on: June 15, 2016, 10:03:37 pm »
+1

Fixed the Dave Goldthorpe / LibraryAdventurer issue by using \b word matches (their names were showing up as cards). I tried matching case-insensitive, but it was bad; way too many false positives. Version 1.13 is published. Thanks again Deadlock!
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

LibraryAdventurer

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1794
  • Shuffle iT Username: LibraryAdventurer
  • I wish my username had the links like it once did.
  • Respect: +1674
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #95 on: June 16, 2016, 12:40:57 am »
+1

Fixed the Dave Goldthorpe / LibraryAdventurer issue by using \b word matches (their names were showing up as cards)...
my name is made of cards.

GendoIkari

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 9701
  • Respect: +10741
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #96 on: June 16, 2016, 12:00:59 pm »
0

Fixed the Dave Goldthorpe / LibraryAdventurer issue by using \b word matches (their names were showing up as cards)...
my name is made of cards.

Sure, but it seemed wrong to autolink them. Because if someone types "LibraryAdventurer", they are almost definitely talking about you, the forum poster, not talking about Dominion cards by that name.

The drawback of matching on words is that words like "Coppers" no longer link the "Copper" part.
Logged
Check out my F.DS extension for Chrome! Card links; Dominion icons, and maybe more! http://forum.dominionstrategy.com/index.php?topic=13363.0

Thread for Firefox version:
http://forum.dominionstrategy.com/index.php?topic=16305.0

LibraryAdventurer

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1794
  • Shuffle iT Username: LibraryAdventurer
  • I wish my username had the links like it once did.
  • Respect: +1674
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #97 on: June 16, 2016, 09:06:21 pm »
0

Fixed the Dave Goldthorpe / LibraryAdventurer issue by using \b word matches (their names were showing up as cards)...
my name is made of cards.

Sure, but it seemed wrong to autolink them. Because if someone types "LibraryAdventurer", they are almost definitely talking about you, the forum poster, not talking about Dominion cards by that name.

The drawback of matching on words is that words like "Coppers" no longer link the "Copper" part.
but I like my name to link to the cards

Seprix

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 5607
  • Respect: +3676
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #98 on: June 16, 2016, 09:10:49 pm »
+2

Now we need a Chrome extension to access f.ds when it is down.
Logged
DM me for ideas on a new article, either here or on Discord (I check Discord way more often)

LibraryAdventurer

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1794
  • Shuffle iT Username: LibraryAdventurer
  • I wish my username had the links like it once did.
  • Respect: +1674
    • View Profile
Re: Chrome Extension for f.ds!
« Reply #99 on: July 25, 2016, 01:54:37 am »
0

I posted a kingdom here, using the card image button to show images, and the images wouldn't show for any card that has a space in its name.
EDIT: I found a workaround which may help you to find the bug: When I capitalized Hunting_Party, Horn_of_Plenty, and Hunting_Grounds, then the images showed correctly. (It took me two tries for Horn of plenty because I tried 'Horn_Of_Plenty' first.)

Also, how do you use the kingdom button in the fds plugin?
« Last Edit: July 25, 2016, 02:00:13 am by LibraryAdventurer »
Logged
Pages: 1 2 3 [4] 5 6 ... 9  All
 

Page created in 0.172 seconds with 21 queries.