Skip to content

Commit

Permalink
Latest code!
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam committed May 21, 2022
1 parent 2fe3b8b commit f0f7356
Show file tree
Hide file tree
Showing 1,362 changed files with 438,555 additions and 98,372 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ build/Release
node_modules/
jspm_packages/

ignore/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

Expand Down
45 changes: 40 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, protocol, BrowserWindow, shell, ipcMain, session } from "electron"
import { app, protocol, BrowserWindow, shell, ipcMain, session, dialog } from "electron"
const path = require("path")
const fs = require('fs')
const rename = require('deep-rename-keys')
Expand Down Expand Up @@ -71,15 +71,15 @@ function lookupResource(pathName: string, resourceMap: Map<string, any>, propert
if (resourceMap.has(key)) {
var data = resourceMap.get(key);

if ((resource = lookupInJson(data, subsplits, name)) !== null)
if ((resource = lookupInJson(data, subsplits, name)))
return resource;
}
}

for (const language of resourceMap) {
let json = language[1];

if ((resource = lookupInJson(json, subsplits, name)) !== null)
if ((resource = lookupInJson(json, subsplits, name)))
return resource;
}
}
Expand Down Expand Up @@ -160,18 +160,34 @@ app.whenReady().then(() => {
callback(pathname);
});

session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ["*://*.discord.com/", "*://*.discord.gg/"] }, (details, callback) => {
session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ["*://*.discord.com/*", "*://*.discord.gg/*", "*://discord.com/*"] }, (details, callback) => {
details.requestHeaders['User-Agent'] = 'DiscordBot (https://github.com/WamWooWam/WinRTElectron, 1.0.0)';
callback({ cancel: false, requestHeaders: details.requestHeaders });
});

app.on('session-created', (session) => {
console.log(session)

session.protocol.registerFileProtocol("ms-appx", appxUriHandler);
session.protocol.registerFileProtocol("ms-appx-web", appxUriHandler);
session.protocol.registerFileProtocol('file', (request, callback) => {
const pathname = decodeURIComponent(request.url.replace('file:///', ''));
callback(pathname);
});
session.webRequest.onBeforeSendHeaders({ urls: ["*://*.discord.com/*", "*://*.discord.gg/*", "*://discord.com/*"] }, (details, callback) => {
details.requestHeaders['User-Agent'] = 'DiscordBot (https://github.com/WamWooWam/WinRTElectron, 1.0.0)';
callback({ cancel: false, requestHeaders: details.requestHeaders });
});
})


let win = new BrowserWindow({
width: 1440,
height: 900,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
nodeIntegrationInSubFrames: true,
webviewTag: true,
webSecurity: false, // fuck you.
contextIsolation: false,
Expand All @@ -180,6 +196,25 @@ app.whenReady().then(() => {
autoHideMenuBar: true,
});

ipcMain.on("windows.storage.pickers.fileopenpicker", async (e, arg) => {
let properties = ["dontAddToRecent"];
if (arg.data.mode != 'single-file')
properties.push("multiSelections");

let filters: Electron.FileFilter[] = [{
name: 'Selected Files',
extensions: [...(<string[]>arg.data.fileTypeFilter).map(x => x.length > 1 ? x.substr(1) : x)]
}];

let result = await dialog.showOpenDialog(win, {
buttonLabel: arg.data.commitButtonText,
properties: <any>properties,
filters: filters
})

e.reply(arg.responseChannel, result.filePaths);
});

win.webContents.on("will-navigate", (event: Electron.Event, url: string) => {
var uri = new URL(url);
if (uri.protocol !== "ms-appx") {
Expand All @@ -188,5 +223,5 @@ app.whenReady().then(() => {
}
});

win.loadURL("ms-appx://wankerr.desktop1/index.html")
win.loadURL("ms-appx://wankerr.desktop/index.html")
});
82 changes: 41 additions & 41 deletions packages/microsoft.bingnews/Common/js/articlereader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7299,47 +7299,6 @@ WinJS.Namespace.define('CommonJS', { Version: 'latest' });
else {
return defaultImpressionContext
}
}, getPageImpressionPartnerCodeAndAttributes: function getPageImpressionPartnerCodeAndAttributes() {
var state = this._state;
var results = {};
if (state && state.entryPoint === Platform.Instrumentation.InstrumentationArticleEntryPoint.partnerPano) {
results.partnerCode = state.instrumentationId
}
if (state && state.pageId) {
var attributes = {};
attributes.pageId = state.pageId;
if (state.clusterId) {
attributes.clusterId = state.clusterId
}
if (state.pageType) {
attributes.pageType = state.pageType
}
results.attributes = attributes
}
return results
}, _defaultArticleChanged: function _defaultArticleChanged(event) {
var state = this._state;
var clientArticleId = event.detail.clientArticleId;
state.initialArticleId = clientArticleId;
var instrumentationData = event.detail.instrumentationData;
if (instrumentationData) {
this._recordArticleView(instrumentationData)
}
}, _defaultArticleError: function _defaultArticleError(event) {
var error = event.detail;
var message = error ? error.message : "";
if (!message && error.webErrorStatus) {
message = "webErrorStatus = " + error.webErrorStatus;
if (error.uri) {
message += (" when visiting " + error.uri)
}
}
var stack = error ? error.stack : "";
Microsoft.Bing.AppEx.Telemetry.FlightRecorder.logCodeError(Microsoft.Bing.AppEx.Telemetry.LogLevel.normal, Microsoft.Bing.AppEx.Telemetry.RuntimeEnvironment.javascript, message, stack)
}, _getSettingsContainer: function _getSettingsContainer() {
var localSettings = Windows.Storage.ApplicationData.current.localSettings;
var container = localSettings.createContainer("articleReaderSettings", Windows.Storage.ApplicationDataCreateDisposition.always);
return container
}, _writeSettings: function _writeSettings() {
var container = this._getSettingsContainer();
var settings = this._settings;
Expand Down Expand Up @@ -7390,6 +7349,47 @@ WinJS.Namespace.define('CommonJS', { Version: 'latest' });
textSize: containerTextSize || optimalTextSize || sizeDefault, textStyle: containerTextStyle || styleDefault
};
this._settings = settings
}, getPageImpressionPartnerCodeAndAttributes: function getPageImpressionPartnerCodeAndAttributes() {
var state = this._state;
var results = {};
if (state && state.entryPoint === Platform.Instrumentation.InstrumentationArticleEntryPoint.partnerPano) {
results.partnerCode = state.instrumentationId
}
if (state && state.pageId) {
var attributes = {};
attributes.pageId = state.pageId;
if (state.clusterId) {
attributes.clusterId = state.clusterId
}
if (state.pageType) {
attributes.pageType = state.pageType
}
results.attributes = attributes
}
return results
}, _defaultArticleChanged: function _defaultArticleChanged(event) {
var state = this._state;
var clientArticleId = event.detail.clientArticleId;
state.initialArticleId = clientArticleId;
var instrumentationData = event.detail.instrumentationData;
if (instrumentationData) {
this._recordArticleView(instrumentationData)
}
}, _defaultArticleError: function _defaultArticleError(event) {
var error = event.detail;
var message = error ? error.message : "";
if (!message && error.webErrorStatus) {
message = "webErrorStatus = " + error.webErrorStatus;
if (error.uri) {
message += (" when visiting " + error.uri)
}
}
var stack = error ? error.stack : "";
Microsoft.Bing.AppEx.Telemetry.FlightRecorder.logCodeError(Microsoft.Bing.AppEx.Telemetry.LogLevel.normal, Microsoft.Bing.AppEx.Telemetry.RuntimeEnvironment.javascript, message, stack)
}, _getSettingsContainer: function _getSettingsContainer() {
var localSettings = Windows.Storage.ApplicationData.current.localSettings;
var container = localSettings.createContainer("articleReaderSettings", Windows.Storage.ApplicationDataCreateDisposition.always);
return container
}, _updateDefaultTextSize: function _updateDefaultTextSize(relayout) {
var container = this._getSettingsContainer();
var containerTextSize = container.values["textSize"];
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
{"clustersDefinition":[{"isFREOffline":1,"editorial":true,"pinned":true,"title":"_TopStory_","guid":"hero","clusterType":"NewsApp.Controls.HeroControl","providerConfiguration":{"providerType":"NewsApp.DataProviders.CMS.DataProvider","categoryKey":"hero","strategy":"hero"}}]}
{
"clustersDefinition": [
{
"isFREOffline": 1,
"editorial": true,
"pinned": true,
"title": "_TopStory_",
"guid": "hero",
"clusterType": "NewsApp.Controls.HeroControl",
"providerConfiguration": {
"providerType": "NewsApp.DataProviders.CMS.DataProvider",
"categoryKey": "hero",
"strategy": "hero"
}
}
]
}
Loading

0 comments on commit f0f7356

Please sign in to comment.