Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Extension v1.0.2 | Software v1.01
Browse files Browse the repository at this point in the history
  • Loading branch information
anKordii committed Apr 18, 2021
1 parent 6569429 commit 91cb743
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Application/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cyou.4uss.app",
"productName": "Browser Discord Status",
"version": "1.0.0",
"version": "1.0.1",
"description": "This is just a socket for browser extension called Browser Discord Status",
"main": "src/index.js",
"scripts": {
Expand Down
32 changes: 11 additions & 21 deletions Application/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ var lastTitle = 'unset';
var lastUrl = 'unset';
var socketStatus = 1;

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
if (require('electron-squirrel-startup')) {
app.quit();
}

Expand Down Expand Up @@ -121,21 +120,13 @@ const createWindow = () => {

};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
});

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
Expand All @@ -144,15 +135,13 @@ app.on('activate', () => {
discord.updatePresence({
details: 'Przeglądanie internetu',
startTimestamp: Date.now(),
largeImageKey: 'chrome',
largeImageKey: 'global',
largeImageText: 'google.com',
smallImageKey: 'download',
smallImageText: 'www.4uss.cyou/chrome-discord',
smallImageText: '4uss.cyou/chrome-discord',
instance: true,
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
io.on('connection', function (socket) {
var $ipAddress = socket.handshake.headers['x-forwarded-for'];

Expand All @@ -168,19 +157,19 @@ io.on('connection', function (socket) {
/* Przyjmowanie*/
socket.on('ussDiscordActive', (data) => {

chromeStatusRPC(data.url, data.title)
chromeStatusRPC(data.url, data.title, data.notSuppoerted)

});

socket.on('ussDiscordUpdate', (data) => {

chromeStatusRPC(data.url, data.title)
chromeStatusRPC(data.url, data.title, data.notSuppoerted)

});

socket.on('requestedDataChrome', (data) => {

if(data.title != lastTitle || data.url != lastUrl) return chromeStatusRPC(data.url, data.title);
if(data.title != lastTitle || data.url != lastUrl) return chromeStatusRPC(data.url, data.title, data.notSuppoerted);

});

Expand All @@ -191,7 +180,7 @@ io.on('connection', function (socket) {

});

function chromeStatusRPC(url, title){
function chromeStatusRPC(url, title, notSuppoerted){

if(socketStatus === 0) return;

Expand All @@ -211,13 +200,14 @@ function chromeStatusRPC(url, title){
if(res.statusCode === 200){
customChromeStatusRPC(ussModificated, data[0].name, data[0].image)
}else{
if(notSuppoerted === 'true') return;
discord.updatePresence({
details: ussModificated,
startTimestamp: Date.now(),
largeImageKey: 'chrome',
largeImageKey: 'global',
largeImageText: ussModificatedU,
smallImageKey: 'download',
smallImageText: 'www.4uss.cyou/chrome-discord',
smallImageText: '4uss.cyou/chrome-discord',
instance: true,
})
}
Expand All @@ -236,7 +226,7 @@ function customChromeStatusRPC(title, name, image){
largeImageKey: image,
largeImageText: name,
smallImageKey: 'download',
smallImageText: 'www.4uss.cyou/chrome-discord',
smallImageText: '4uss.cyou/chrome-discord',
instance: true,
});
}
2 changes: 1 addition & 1 deletion Extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"manifest_version": 2,
"name": "Browser Discord Status",
"permissions": [ "tabs", "notifications" ],
"version": "1.0.1.1"
"version": "1.0.2"
}
2 changes: 1 addition & 1 deletion Extension/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<h3>Settings</h3>
</div>
<div class="col-md-12">
<div class="form-check"><input class="form-check-input" type="checkbox" id="disableNot" disabled=""><label class="form-check-label" for="disableNot">Disable not supported sites</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="disableNot"><label class="form-check-label" for="disableNot">Disable not supported sites</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="disableGoogle"><label class="form-check-label" for="disableGoogle">Disable Google Search</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="incognitoMode" disabled=""><label class="form-check-label" for="incognitoMode">Incognito Mode</label></div>
</div>
Expand Down
33 changes: 11 additions & 22 deletions Extension/xayooindustries.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ if(!localStorage.disableGoogle){localStorage.disableGoogle = false;};
// 👇 Powiadomienie o zainstalowaniu dodatku
if(!localStorage.firstInstalll){ localStorage.firstInstalll = 'none'};
// 👇 Not connected
chrome.browserAction.setBadgeBackgroundColor({ color: "#b30b2f" }); chrome.browserAction.setBadgeText({ text: "Offline" })
chrome.browserAction.setBadgeBackgroundColor({ color: "#b30b2f" }); chrome.browserAction.setBadgeText({ text: "OFF" })


socket.on('connect', function(){
alercik('Connected to the server');
chrome.browserAction.setBadgeBackgroundColor({ color: "#00bd8a" })
chrome.browserAction.setBadgeText({ text: "Online" })
chrome.browserAction.setBadgeBackgroundColor({ color: "#006b1e" })
chrome.browserAction.setBadgeText({ text: "ON" })
});
socket.on('disconnect', function () {
alercik('Server connection lost');
chrome.browserAction.setBadgeBackgroundColor({ color: "#b30b2f" })
chrome.browserAction.setBadgeText({ text: "Offline" })
chrome.browserAction.setBadgeText({ text: "OFF" })
});
socket.on("currentData", function(){

Expand All @@ -34,11 +34,10 @@ chrome.tabs.onActivated.addListener( function(activeInfo){

if (!y || ['chrome://', 'about://'].some(p => y.startsWith(p))) return;
if (!y || ['https://www.google.com', 'https://google.com', 'http://www.google.com', 'http://google.com'].some(p => y.startsWith(p) && localStorage.getItem(`disableGoogle`) === 'true')) return;
//if(!y || getStatus(y) == 'blocked' && localStorage.getItem(`disableNot`) === 'true') return;

socket.emit("ussDiscordActive", {
url: y,
title: tab.title
title: tab.title,
notSuppoerted: localStorage.disableNot
});

});
Expand All @@ -48,13 +47,13 @@ chrome.tabs.onUpdated.addListener((tabId, change, tab) => {

if (!change.url || ['chrome://', 'about://'].some(p => change.url.startsWith(p))) return;
if (!change.url || ['https://www.google.com', 'https://google.com', 'http://www.google.com', 'http://google.com'].some(p => change.url.startsWith(p) && localStorage.getItem(`disableGoogle`) === 'true')) return;
//if (!change.url || getStatus(change.url) == 'blocked' && localStorage.getItem(`disableNot`) === 'true') return;

if (tab.active && change.url) {

socket.emit("ussDiscordUpdate", {
url: change.url,
title: tab.title
title: tab.title,
notSuppoerted: localStorage.disableNot
});
}
});
Expand All @@ -64,11 +63,11 @@ function currentPageData(){

if (!tab.url || ['chrome://', 'about://'].some(p => tab.url.startsWith(p))) return;
if (!tab.url || ['https://www.google.com', 'https://google.com', 'http://www.google.com', 'http://google.com'].some(p => tab.url.startsWith(p) && localStorage.getItem(`disableGoogle`) === 'true')) return;
//if(!tab.url || getStatus(tab.url) == 'blocked' && localStorage.getItem(`disableNot`) === 'true') return;

socket.emit("requestedDataChrome", {
url: tab.url,
title: tab.title
title: tab.title,
notSuppoerted: localStorage.disableNot
});
});
}
Expand All @@ -79,14 +78,4 @@ function alercik(title){
if (localStorage.firstInstalll == "none") {
chrome.notifications.create({ message: `Thank you for installing the Browser Discord Status extension. You will display what are u doing in browser on discord.`, contextMessage: "You can controll your status via extension settings and external app.", title: "Welcome to Browser Discord Status", type: "basic", iconUrl: "../../icons/128.png" }, function () { });
localStorage.setItem('firstInstalll', 'disable');
}
/*async function getStatus(url){
const chars = url.split('/');
let data = await fetch(`https://api.4uss.cyou/usslist.php?url=${chars[2]}`)
.then(function(response) {
if(response.status === 404){
return response.status;
}
});
return data;
}*/
}

0 comments on commit 91cb743

Please sign in to comment.