Skip to content

Instantly share code, notes, and snippets.

@MarkyMarkNo1
Created January 24, 2016 16:29
Show Gist options
  • Save MarkyMarkNo1/02a0b4999f68f89dc436 to your computer and use it in GitHub Desktop.
Save MarkyMarkNo1/02a0b4999f68f89dc436 to your computer and use it in GitHub Desktop.
For unknown reasons, AVM limits the FRITZ!Box Internet Radio stations lists (Heimnetz -> Mediaserver -> Internetradio) to max. 40 entries (FRITZ!OS v06.30). This snippet adds further stations to the list. Just adjust four lines below, then copy all, paste and execute in your browsers console.
/**
* For unknown reasons, AVM limits the FRITZ!Box Internet Radio stations lists
* (Heimnetz -> Mediaserver -> Internetradio) to max. 40 entries
* (FRITZ!OS v06.30).
*
* This snippet adds further stations to the list. Just adjust four lines below,
* then copy all, paste and execute in your browsers console.
*
* function sendData taken from
* https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_forms_through_JavaScript#Building_an_XMLHttpRequest_manually
*/
(function sendData() {
var sid = '1234567890123456'; // <== Set to current Fritz!Box session ID
var data = {
SrcId: 40, // <== Set to current length of your internet radio stations list, increment if repeated
src_name: 'Radio station name goes here', // <== Adjust radio station name
src_url: 'http://radio.station/stream/url/goes/here', // <== Adjust radio station stream url
/* No need to change anything below this line */
src_fon_cnt: 0,
src_fon_cnt_all: 6,
newSrc: 1,
back_to_page: '/dect/internetradio.lua',
SrcType: 'ir',
btn_save:''
};
/* function sendData taken from
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_forms_through_JavaScript#Building_an_XMLHttpRequest_manually */
var XHR = new XMLHttpRequest();
var urlEncodedData = "";
var urlEncodedDataPairs = [];
var name;
// We turn the data object into an array of URL encoded key value pairs.
for(name in data) {
urlEncodedDataPairs.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name]));
}
// We combine the pairs into a single string and replace all encoded spaces to
// the plus character to match the behaviour of the web browser form submit.
urlEncodedData = urlEncodedDataPairs.join('&').replace(/%20/g, '+');
// We define what will happen if the data is successfully sent
XHR.addEventListener('load', function(event) {
alert('Yeah! Data sent and response loaded.');
});
// We define what will happen in case of error
XHR.addEventListener('error', function(event) {
alert('Oups! Something goes wrong.');
});
// We setup our request
XHR.open('POST', '/dect/source_edit.lua?sid=' + sid);
// We add the required HTTP header to handle a form data POST request
XHR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// XHR.setRequestHeader('Content-Length', urlEncodedData.length);
// And finally, We send our data.
XHR.send(urlEncodedData);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment