Jump to content

Can anyone tell me what language this is in?

Go to solution Solved by T.Vengeance,

Javascript

/*

* Block.si Chrome Extension

* background.js: Handles extension settings.

* Authors: Patrick Zver, Žiga Å pindler, Samo BraÄić

*/

 

/*jshint unused:false */


 

// var apikey = 'LLCvXwS3FrcfkhraRREft8Ib4',

//    cache = [], // disabled caching of getRating responses since now server sends Expire headers and Chrome manages the caching

var s;

 

// Set cloud settings

// ------------------

 

// Copy userData object into Chrome Storage.

function updateChromeSettings() {

   chrome.storage.sync.set({

       BlocksiSettingsV2: s // TODO: better handle migration from old settings. since only webfilter and youtube settings are incompatible

       // tempfix: renamed settings to V2.

   });

}

 

// Get settings from Blocksi Manager

// ---------------------------------

 

// Request user settings from Block.si Manager and set them as local settings.

function getManagerSettings(userName, validationCode) {

 

   // Request settings from service.block.si

   var i, len, name,

       reqUrl = 'http://service.block.si/getSettingsByUserId?' +

       'userId=' + userName + '&' +

       'validation=' + validationCode + '&' +

       'apikey=' + apikey;

 

   getJSON(reqUrl, true, function(data) {

 

       // Copy into local settings.

       var reqSettings;

       if (typeof(data) === 'string') {

           reqSettings = JSON.parse(data);

       } else {

           reqSettings = data;

       }

 

       if (reqSettings.Status === 'true') {

 

           // 1. User Data

           s = new UserData(userName, validationCode);

           s.companyId = reqSettings.CompanyId;

 

           // 1.2 Password.

           if (reqSettings.PassStatus === 'true') {

               s.password = [true, reqSettings.Password];

           } else {

               s.password = [true, ''];

           }

           console.log("filter :"+reqSettings.FilterSettings);

   console.log("youtube filter:"+reqSettings.YTFilter);

           // 2.1 Web filters

 

           // fix: first all categories, then all subcategories

           var fix = [49, 38, 32, 17, 8, 5];

           var arr = reqSettings.FilterSettings.split('');

           len = fix.length;

           for (i = 0; i < len; i++) {

               var p = arr.splice(fix, 1)[0];

               console.log(fix, p);

               arr.reverse().push(p);

               arr.reverse();

           }

           len = Object.keys(s.userSettings.webFilter).length;

           for (i = 0; i < len; i++) {

               name = Object.keys(s.userSettings.webFilter);

               s.userSettings.webFilter[name].a = parseInt(arr, 10);

           }

 

            // 2.2 Youtube settings

 

           if (reqSettings.YTFilter !== null) {

 

               // 2.2.1 Youtube

 

               //len = s.userSettings.ytFilter.length;

 

var ii=0;

 

for(nameYT in s.userSettings.ytFilter){

 

s.userSettings.ytFilter[nameYT].a = parseInt(reqSettings.YTFilter.charAt(ii), 10);

console.log(nameYT);

console.log(s.userSettings.ytFilter[nameYT].a);

ii++;

 

}

 

           }

           // 2.3 Black and White list

           len = reqSettings.List.length;

           for (i = 0; i < len; i++) {

               s.userSettings.bwList.push(reqSettings.List);

           }

 

           // 2.4 Regular expression list

           len = reqSettings.RegEx.length;

           for (i = 0; i < len; i++) {

               s.userSettings.regExList.push(reqSettings.RegEx);

           }

 

           // 2.5 Access Time

           if (reqSettings.ATProfile !== null) {

               s.userSettings.AccTimeEnabled = true;

               s.userSettings.AccTimes = [[],[],[],[],[],[],[]];

 

               // too much var

               len = reqSettings.ATProfile.length;

               for (i = 0; i < len; i++) {

                   if (reqSettings.ATProfile !== '00:00_24:00') {

 

                       // ["09:01", "12:01"]

                       var timeArr = reqSettings.ATProfile.split('_');

 

                       var now = new Date(),

                           midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);

 

                       var t1 = 0,

                           t4 = 86400000;

 

                       // [9, 1], [12, 1]

                       var t2 = [parseInt(timeArr[0].substring(0, 2), 10), parseInt(timeArr[0].substring(3, 5), 10)],

                           t3 = [parseInt(timeArr[1].substring(0, 2), 10), parseInt(timeArr[1].substring(3, 5), 10)];

 

                       var from = new Date(now.getFullYear(), now.getMonth(), now.getDate(), t2[0], t2[1], 0),

                           till = new Date(now.getFullYear(), now.getMonth(), now.getDate(), t3[0], t3[1], 0);

 

                       var diff1 = from.getTime() - midnight.getTime(), // diff in miliseconds

                           diff2 = till.getTime() - midnight.getTime(); // diff in miliseconds

 

                       s.userSettings.AccTimes.push([t1, diff1], [diff2, t4]);

 

                   }

               }

           }

           // 3. Update chrome storage.

           updateChromeSettings();

       }

   });

}

 

// Get settings from cloud

// -----------------------

 

// Copy Chrome Storage settings into userData object.

function updateLocalSettings() {

   chrome.storage.sync.get('BlocksiSettingsV2', function(data) {

       /*if (data.BlocksiSettingsV2) {

           // Load local settings from Chrome Storage into userData object.

           s = data.BlocksiSettingsV2;

console.log("if 1 "+s.userName+" , "+s.validationCode);

           /*chrome.browserAction.enable();

           chrome.browserAction.setTitle({

               title: 'Add to black/white list'

           });

           chrome.browserAction.setBadgeText({

               text: ''

           });*/

 

           // If Blocksi Manager is used, reload the user data.

           // & disable browser action

         //  if (s.userName && s.validationCode) {

           //    getManagerSettings(s.userName, s.validationCode);

 

               // disable browser icon

              /* chrome.browserAction.disable();

               chrome.browserAction.setTitle({

                   title: 'Manager is used'

               });

               chrome.browserAction.setBadgeText({

                   text: 'M'

               });*/

          // }

      // } else {

   s=new UserData(false,false);

console.log("if 2 "+s.userName+" , "+s.validationCode);

           // Default settings.

   if(s.userName && s.validationCode)

getManagerSettings(s.userName,s.validationCode);

   else

            updateChromeSettings();

 

           // It's first installation, open Options page.

           /*chrome.tabs.create({

               url: 'quick-setup.html'

           });*/

       //}

   });

}

// Check if Local settings exist. Otherwise it's a new installation, set User settings to default.

updateLocalSettings();

 

// Black & White list

// ------------------

 

// Add URL to Black & White list

function addURLtoBW(url, action) {

   var len = s.userSettings.bwList.length;

 

   if (len === 0) {

       s.userSettings.bwList.push([url, action]);

       updateChromeSettings();

       return;

   }

 

   for (var i = 0; i < len; i++) {

       // Update action, if URL already exists.

       if (s.userSettings.bwList[0] === url || s.userSettings.bwList[0].indexOf(url) !== -1) {

           s.userSettings.bwList[1] = action;

           updateChromeSettings();

           break;

       }

 

       // Add URL, if it doesn't exist yet.

       if (i === len - 1) {

           s.userSettings.bwList.push([url, action]);

           updateChromeSettings();

       }

   }

}

 

// Return Action for item in Black & White list

function getBWaction(url) {

   var len = s.userSettings.bwList.length;

 

   if (len === 0) {

       return 0;

   }

 

   for (var i = 0; i < len; i++) {

       if (s.userSettings.bwList[0] === url) {

           return s.userSettings.bwList[1];

       }

 

       if (i === len - 1) {

           return 0;

       }

   }

}

 

// Event listener

// --------------

 

// Listen for changes made by Options page.

chrome.storage.onChanged.addListener(function(changes, areaName) {

   // Update userData object from Chrome Storage.

   console.log('              LISTENER: setting changed              ');

   updateLocalSettings();

});

 

// Listen for messages from content script.

// Listen for messages from content script.

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {

   if (request.regex !== undefined) {

       // Regex checking is done in the script.

       sendResponse({

           Regex: s.userSettings.regExList

       });

   } else if (request.warning !== undefined) {

       // If message includes a variable 'warning', it was sent by warning.php page.

       if (request.warning === 'Allow') {

           // Add URL to Black & White list, so the warning doesn't display next time.

           console.log(request.url);

           var url = parseUri(decodeURIComponent(request.url));

           addURLtoBW( url.hostname, 0);

           // Reload the currently selected tab.

           chrome.tabs.update(sender.tab.id, {

               url: url.href

           });

       } else {

           // Close curently selected tab.

           chrome.tabs.remove(sender.tab.id);

       }

   }

});

 

chrome.webRequest.onBeforeRequest.addListener(function(details) {

   console.log('onBeforeRequest');

       return pageCheck(details.url);

 

   }, { urls: ['<all_urls>'], types: ['main_frame']}, ['blocking']

);

 

// handles html5 history changes

chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {

   console.log('onHistoryStateUpdated');

   var blockData = pageCheck(details.url);

   if (blockData !== undefined && 'redirectUrl' in blockData) {

       chrome.tabs.update(details.tabId, {

           url: blockData.redirectUrl

       });

   }

});

 

 

this was in the schools web filter pre installed on the chrome book and i was wondering what it was written in? If you cant tell i can probably find more code.

Link to comment
Share on other sites

Link to post
Share on other sites

Looks like English to me.

Yeah, what he said.

 

Though, I think he means a programming language of course :P

Main Rig: CPU: AMD Ryzen 7 5800X | RAM: 32GB (2x16GB) KLEVV CRAS XR RGB DDR4-3600 | Motherboard: Gigabyte B550I AORUS PRO AX | Storage: 512GB SKHynix PC401, 1TB Samsung 970 EVO Plus, 2x Micron 1100 256GB SATA SSDs | GPU: EVGA RTX 3080 FTW3 Ultra 10GB | Cooling: ThermalTake Floe 280mm w/ be quiet! Pure Wings 3 | Case: Sliger SM580 (Black) | PSU: Lian Li SP 850W

 

Server: CPU: AMD Ryzen 3 3100 | RAM: 32GB (2x16GB) Crucial DDR4 Pro | Motherboard: ASUS PRIME B550-PLUS AC-HES | Storage: 128GB Samsung PM961, 4TB Seagate IronWolf | GPU: AMD FirePro WX 3100 | Cooling: EK-AIO Elite 360 D-RGB | Case: Corsair 5000D Airflow (White) | PSU: Seasonic Focus GM-850

 

Miscellaneous: Dell Optiplex 7060 Micro (i5-8500T/16GB/512GB), Lenovo ThinkCentre M715q Tiny (R5 2400GE/16GB/256GB), Dell Optiplex 7040 SFF (i5-6400/8GB/128GB)

Link to comment
Share on other sites

Link to post
Share on other sites

Javascript

Specs: CPU - Intel i7 8700K @ 5GHz | GPU - Gigabyte GTX 970 G1 Gaming | Motherboard - ASUS Strix Z370-G WIFI AC | RAM - XPG Gammix DDR4-3000MHz 32GB (2x16GB) | Main Drive - Samsung 850 Evo 500GB M.2 | Other Drives - 7TB/3 Drives | CPU Cooler - Corsair H100i Pro | Case - Fractal Design Define C Mini TG | Power Supply - EVGA G3 850W

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×