Category Archives: Uncategorized

Userscript for highlighting reposted songs on soundcloud

Download provided at the end of this post.

If there is anything wrong with the script or Soundcloud does a redesign, feel free to reach out to me via my contact form.

Backstory

Very occasionally I head on over to SoundCloud to check out some local artists or mixes from various artists.

I dont really classify myself as a music nut, I just want to load up my stream page and see a bunch of curated music.

However a couple of years ago I noticed that “reposts” appear to be a trend with the new soundcloud design.

I understand there is a need for artists to bump their music to promote it, and ensure it isnt immediately buried, However it makes finding new music really hard to find – and most of that can be attributed to soundcloud. I cant find any easy way to hide reposts. Maybe an option already exists – or maybe one will get added after I make this post.

Anyway I finally bit the bullet and wrote a really basic user-script that will very in-elegantly differentiate the reposted songs from the newly posted songs.

The script implements a static button that follows you as you scroll through stream page of SoundCloud. Because the stream page lazily loads more content as you reach the end of the page, you will have to press the button each time more content is loaded.

Snapshot of the script in action

What are Userscripts?

Userscripts are almost like modifications for websites that anyone can write (in this case I wrote this one myself) they run java-script on the page after it has finished loading.
WARNING: never install user-scripts from unknown sources (even be careful on pages like mine)

Install TamperMonkey

If you don’t already have TamperMonkey we will need to install it to use this script
Tamper monkey is a plugin that allows you to run Userscripts on webpages.

Chrome: Search “TamperMonkey” on google, or the google Appstore
Firefox: Search for “TamperMonkey” on the Mozilla plugin store

Install the Soundcloud Repost Highlight script

Once you have the required plugins you should just be able to click the link below and the plugin will handle the remaining installation.

Download Soundcloud Repost Highlighter Script

Each time you load the /stream/ page on SoundCloud you should be able to use the new button to colour the reposts.

Steam Marketplace script updated!

For years I have been developing a userscript for the steam market, and slowly adding features to it. I’m taking some time out to post about it here!

To use this script, you need to install an addon for userscripts
Greasemonkey (for Firefox) or TamperMonkey (for Chrome)
ONLY INSTALL USERSCIPTS FROM SOURCES YOU TRUST

Lets run through the current features!

– increased visibility for firefox users using enhanced steam
– Be able to hide “My Active Listings” section to reduce clutter if you have heaps of items listed
– Clearly details CSGO skins that have nametags attached on listing pages
– Calculates totals for all your “Active Listings” on the market menu
– Compacts the css theme so more listings fit on the page when searching
– A toggleable feature, for searching CSGO items with nametags, that instantly closes the tab if no items on the page has a nametag

This script is designed to by run along side enhanced steam!

Download Link: [Current version found on my Dropbox]

I may make an instructional video later on some of the features!

Disclaimer #1: Enhanced steam already does some similar things, but I recreated them to suit my personalised taste, also Enhanced steam is no longer supported on firefox,
whereas my script works perfectly fine on firefox
My script also fixes a lot of issues with the abandoned version of enhanced steam for firefox.

Disclaimer #2: Steam inventory helper also shows you which csgo skins have nametags,
but with my script  its much more obvious as it makes it blatantly obvious when the first few items have a name tag on the marketplace.

Steam Marketplace UserScript

I have since updated this script, Read the newest blog post on this topic here:

http://p337.info/blog/steam-marketplace-script-updated/

 

So I spent last night trying to combat an issue with the Steam Marketplace,
CS:GO is my new favorite game, and offloading all the sticker capsules and skins has left my marketplace transaction sales list quite long,  Meaning I have 14 items to scroll past before I get to the actual sales items

 

I don’t know if anyone could actually benefit from my UserScript,
But It adds the ability to hide your listed marketplace items, and additionally load one of the tabs automatically in the “Market Activity” section further down the page. (instead of always loading the “Popular Items” – which rarely changes)

 

with the settings seen above, my page now loads like the below screenshot without any clicking;
notice That the “My Activity Listings (14)” is collapsed, and “Newly Listed” is already selected by default

 

This user-script utilises HTML5 localStorage functionality in JavaScript, and at the moment is only compatible with Firefox (now compatible with Chrome if you install Tamper monkey), your Firefox version must be above version 3.5 and “dom.storage.enabled” set to true (you’ll only need to check this for per-historic version of Firefox) and you’ll obviously need Greasemonkey installed to run User-scripts.

Ive been using this script for the last 2 years, and editing as I go, I might make a major update soon.

If you are sceptical about whats inside, you can view the code below on Pastebin
As with any external script, make sure you be careful and know what you’re running.

Current Version
http://p337.info/blog/steam-marketplace-script-updated/

EDIT: This is no longer the way I get fitbit steps in my website,

Please see this new post on how I currently get data on my wesbite

http://p337.info/blog/?p=88

Below is the old post that serves historical purposes only.

Ive had a Fitbit Flex for roughly 3 months now, and enjoying every step and achievement that comes along with the band, and the motivation provided by the web dashboard.

However last month I had decided to give my website a complete redesign, and with my new wristband, I felt that I had the ability to display some personalized dynamic content in the form of my daily step total would be awsome, as I had done a similar things when displaying my “Last online” status with the Steam Web API and PHP. Boy was I in for a surprise.

The process for the Fitbit API was immensely more complicated than that of the Steam Web API, Using an authentication process called OAuth, Essentially the process you see when you “Login with Facebook” on several websites, meaning that your PHP application needs to send the users attention onto Fitbit to authenticate the access to their data.

Not to mention, this required me to install “Oauth” PERL script onto my Website, Which I could not do due to the limitations set by my free web hosting setup. This had me trawling through countless 3rd party OAuth PHP Libraries over the last 3 weeks, Which I understood barely any of.

Eventually I found an Oauth setup utilising Google Spreadsheets and Google Scripts, which allowed me to work around my free web-hosting limitations; technical steps being outlined below

If you’re following everything I’ve said up until now, you’re most likely familiar with API’s and more specifically Want to actually use it. Please note: You will also need an understanding/access to a PHP capable server for the implementation of this.

What to actually do

Step 1: Go and get a API key from their website,
(recommending you get a “Browser” and “Read only” API key – See more at wikihow)

Step 2: Login to your Google Drive Account, (as we will be using a Google Script to retrieve Fitbit data for us) and create a new spreadsheet.

Step 3: Once you’re in your new spreadsheet, we will need to open up the Gogole Script Editor (This will open up in a new browser tab)

 

 

 

Note: Once in the script editor; a “Blank project” will be fine to create if you haven’t ventured into script editor before)

Step 4: I used the script from the following GitHub repository (or additionally copy fitbit.js from here) and paste it in a new Blank Google script (remove any code in the blank project you just created), and paste Fitbit.js into the code area.

Step 5: Select and Run “renderFitbitConfigurationDialog” from the drop down menu on the top toolbar, and press the button with the Play symbol.

 

Some pop-up windows for google will open; Click accept or next on all of the authentication steps to allow the script access to your newly made Google spreadsheet

Swap browser tabs back into your Spreadsheet; you should see a configure window shown below,

 

After entering your Consumer and Consumer Secret key like the above screenshot,
Make sure everything else is as you desire, and select “Save Configuration”

Go back into script editor and run the “Authorize” Function

Then proceed to run the “refreshTimeSeries” function to populate your data

Swap back to your spreadsheet, and we should see the below setup.
Cell B3 is the value were interested in as it displays our daily total (and gets replaced each day)

 

Step 6: We need to make sure that our spreadsheet stays active and our steps get updated regularly, so head back into the Google Script Editor, and click “Current Project’s triggers” button

 

My triggers look like this

 

(This will update my spreadsheet from the Fitbit site every 30 minutes)

Step 7: Getting a cell to display on our website
Heres the part where we need to get our value out of the spreadsheet,
Whilst on our spreadsheet = Under “File> Publish to web”, we can extract a cell in a webpage.

 

Copy your URL seen above, we will need it for our PHP manipulation.
(Open the URL in a new browser window if you want to check it is the right cell)

Step 8: Create a new php function or page, and use some basic sub-stringing to get your “B3 Cell” in a form you can use!

function printFitbitSteps() {
$content = file_get_contents(“PUBLIC URL FOR GOOGLE SPREADSHEET CELL B3”);
$content = substr($content, strpos($content, “<td  class=’s0′>”)+16);
$steps = substr($content, 0, strpos($content, “</tr></table></div>”));
echo $steps;
}

The above code reads the HTML given to us in the URL as a variable, and splices it with sub-stringing so that only our step total is left over!

You should now be done,
This assuming you can utilize PHP on your website, and have a knowledge of how it works, but the basic steps are in those lines of code above. Its probably considered dirty coding, but it works for me.

Here is the footer from my website, focusing on the “Steps today” value.

Hopefully this can help someone out!!

References:
http://quantifiedself.com/2013/02/how-to-download-fitbit-data-using-google-spreadsheets/
https://github.com/loghound/Fitbit-for-Google-App-Script

Special Thanks to Manuel Lemos who put in heaps of effort to try and teach me his Oauth PHP Library (I just wasnt smart enough)