NanoAdblocker / NanoCore

An adblocker
GNU General Public License v3.0
463 stars 22 forks source link

(Obsolete) Old Edge (EdgeHTML) build discussion thread #40

Closed jspenguin2017 closed 5 years ago

jspenguin2017 commented 6 years ago

For Chromium-based Edge: https://www.microsoft.com/en-us/microsoft-edge/insider-addons/detail/epbkapkgcmdmfpogenoebpdeibmfinpf

New thread: https://github.com/NanoAdblocker/NanoCore/issues/253


Nano Adblocker is published: https://www.microsoft.com/store/productId/9NSXDX2TDB3V

Nano Defender is in review since May 2018...

Knows issues

Edge does not support listening to web_accessible_resources requests...

![image](https://user-images.githubusercontent.com/7283682/39450821-d88e419c-4c89-11e8-9f4a-e21577b35c5f.png) ![image](https://user-images.githubusercontent.com/7283682/39450907-2365cc6c-4c8a-11e8-836c-650e0da1ca85.png)

 

Edge restores (un-maximize) when browser.tabs.reload or browser.tabs.select is called.

Opening Logger in InPrivate mode breaks cosmetic filtering.

reunicorn commented 6 years ago

You've probably already seen it, but in case you haven't, check out uBlock-Edge. Although it hasn't been updated since July, nikrolls (the maintainer) did find some workarounds for Edge's incompatibility issues, which you might be able to integrate into Nano for Edge.

jspenguin2017 commented 6 years ago

I know that repo, and I plan on looking at it, I just added a 2 lines shim to see how well it performs.

Update: I quickly looked over his code and I don't really like how he did it. I probably will go read the doc and put together a shim from scratch, we'll see how it goes.

kevin12314 commented 6 years ago
Hi, @jspenguin2017 . A few days ago I copied your project to my computer and tried to use nano adblocker on Edge. I used platform\chromium to modify. This my way. In `manifest.json` - `default_icon`,Change `"128": ""img/browsericons/38_on.png""` to `"38": "img/browsericons/128_on.png"` .This change will make Icons show up. - `icons` add `"16": "img/128_on.png",` . This make context menu icon show up. - `background` add "persistent":true. - If you want publish to Windows Store, you need to add `"minimum_edge_version": "41.16299.15.0",` In `vapi-common.js` and `vapi-background.js` - Change `var chrome = self.chrome;` to `var chrome = self.browser;` In `vapi-client.js` - Change `chrome.runtime.connect` to `browser.runtime.connect` In `vapi-webrequest.js` - Change `wrApi = chrome.webRequest;` to `wrApi = browser.webRequest;` In `vapi-background.js` - comment out ```javascript /*var iconPaths = [ { '128': 'img/browsericons/128_off.png' }, { '128': 'img/browsericons/38_on.png' } ]; */ ``` - In `var onTabReady = function(tab, status, badge)` , add ``` javascript var iconPaths = status === 'on' ? { '38': 'img/browsericons/38_on.png' } : { '38': 'img/browsericons/38_off.png' }; ``` - Change ``` javascript browserAction.setIcon({ tabId: tab.id, path: iconPaths[status === 'on' ? 1 : 0] }); ``` to ``` javascript browserAction.setIcon({ tabId: tab.id, path: iconPaths }); ``` Edge will get exception `Property 'path': 'tabId' is not a valid property in the dictionary` if use `path: iconPaths[status === 'on' ? 1 : 0]` In tools folder add `make-edge.sh `. You can copy from `make-chromium.sh`. But you need to add this line `sed -i "s/'fullwide',\s*//g" $DES/js/*.js` after `rm $DES/js/vapi-usercss.js`. Because `time.toLocaleString('fullwide', timeOptions); ` Edge will get exception with 'fullwide' parameter. this code is to remove `'fullwide'` parameter. This my screen shot. ![image](https://user-images.githubusercontent.com/10508800/34067426-8b344614-e260-11e7-9c49-8a3696ce2e74.png) ![image](https://user-images.githubusercontent.com/10508800/34067429-b7e548de-e260-11e7-8be8-55284236f264.png) ![image](https://user-images.githubusercontent.com/10508800/34067452-411cf0b6-e261-11e7-9c14-4278a3cd3bdf.png) dashboard page ![image](https://user-images.githubusercontent.com/10508800/34067459-6984e2ac-e261-11e7-9599-7a00b80880b0.png) background page not get exception. ![image](https://user-images.githubusercontent.com/10508800/34067434-f7da78d8-e260-11e7-9fc8-a4d72cb8c4d9.png)

[Update by jspenguin2017: Folding this post as it is long and already resolved]

jspenguin2017 commented 6 years ago

Amazing! Can you post your changes? Like a patch file or a repo commits?

kevin12314 commented 6 years ago

nano adblocker edge.zip

The file list different from platform\chromium are

cloud-ui.js need change becouse Edge syncs data in the background, so this callback is very fast. It's often faster than initialisation, meaning there's a race condition where the UI is not always ready for the assumptions this function makes. This change is what I found from uBlock-Edge.

jspenguin2017 commented 6 years ago

OK, cool, as Microsoft Store is still full according to Microsoft, we might have to wait a while, I'll start with new Dashboard.

reunicorn commented 6 years ago

Microsoft is slowly but surely adding more extensions to their store. It couldn't hurt to submit Nano AdBlocker and/or Nano Defender for review just to get in the queue. They've added 10 more extensions and are now up to 80 total, which at least shows that they're moving forward with it. I understand if you wanted to add more polish/features/etc. first.

jspenguin2017 commented 6 years ago

If I submit it now, can I update it when it's in the review queue?

jspenguin2017 commented 6 years ago

@kevin12314 Can you copy-paste your custom filters? Something doesn't feel right about the syntax highlighter.

kevin12314 commented 6 years ago
@@/showads.js$domain=shink.in
avlang2.info##div.tac
ck101.com##div.fuckBlockCover>div.playerCover
cool18.com##div.body_center[style='width:1000px;height:270px;']
@@||fas.li^$generichide
!@@||btrll.com^$third-party 
@@|http://$subdocument,domain=iqiyi.com

!UDN購物
@@shopping.udn.com/mall/images/spacer.gif?

!ASUS
@@||googletagmanager.com/gtm.js?$third-party,domain=asus.com

! Windows Central Youtube Block Workaround
@@|blob:$domain=windowscentral.com 

! ‎2017‎年‎2‎月‎9‎日‎ ‎下午‎ ‎11‎:‎39‎:‎12 http://www.hclips.com/videos/18-year-old-japanese-teen-recorded-fucking-her-boyfriend/?promo=1102
www.hclips.com##.pl_1

! ‎2017‎年‎3‎月‎29‎日‎ ‎下午‎ ‎10‎:‎07‎:‎55 https://gnn.gamer.com.tw/0/145260.html
gamer.com.tw###BH-bigbanner

! ‎2017‎年‎4‎月‎18‎日‎ ‎下午‎ ‎11‎:‎44‎:‎51 https://9song.me/2017/04/17/%e7%be%8e%e9%ba%97%e6%9c%aa%e4%ba%a1%e4%ba%ba/
9song.me##a[href^="http://gdot.h978.com/index.phtml"]

! ‎2017‎年‎4‎月‎18‎日‎ ‎下午‎ ‎11‎:‎45‎:‎27 https://9song.me/2017/04/17/%e7%be%8e%e9%ba%97%e6%9c%aa%e4%ba%a1%e4%ba%ba/
9song.me##.entry-inner > .post

! ‎2017‎年‎5‎月‎21‎日‎ ‎下午‎ ‎10‎:‎05‎:‎15 https://www.google.com.tw/search?q=%E5%B7%B4%E5%93%88%E5%A7%86%E7%89%B9&ie=&oe=
google.*##.pdp-psy

! ‎2017‎年‎5‎月‎21‎日‎ ‎下午‎ ‎10‎:‎36‎:‎44 https://www.google.com.tw/maps/@25.005939,121.4565846,13z
www.google.com.tw###pushdown

! ‎2017‎年‎5‎月‎21‎日‎ ‎下午‎ ‎10‎:‎41‎:‎01 https://docs.google.com/document/u/0/
docs.google.com##.gb_g.gb_Mc.gb_Kc.gb_Lc
jspenguin2017 commented 6 years ago

Unicode 8206...?? http://www.fileformat.info/info/unicode/char/200e/index.htm

kevin12314 commented 6 years ago

Those filters were generated through uBlock Origin Block element. If I key in filter like ! 2017年5月20日 下午10:41:01 https://docs.google.com/document/u/0/ It seems that it did not add Unicode 8206.

jspenguin2017 commented 6 years ago

Yea, the guy who did the translation had some weird stuff going on with his IDE. Actually, it's a quirk in Edge.

reunicorn commented 6 years ago

If I submit it now, can I update it when it's in the review queue?

Yes, you can submit as many times as you like and your most recent submission will be the one considered.

kevin12314 commented 6 years ago

@jspenguin2017 I update build scripts use Node.js and remove same files in platform\edge files as in platform\chromium. All update is base on v1.0.0.24 Source code.

File: NanoCore.zip Edge extension: Nano_Edge.zip

jspenguin2017 commented 6 years ago

You are on the beta version of Windows? The latest stable version of Edge is 40.15063.674.0.

jspenguin2017 commented 6 years ago

I don't see what your patch to cloud-ui.js achieve, it waits for the button? Why?

jspenguin2017 commented 6 years ago

browserAction.setIcon in Edge mutates objects that are passed in, WTF?

jspenguin2017 commented 6 years ago

It's more complex than I expected, hum... Still crashing...

jspenguin2017 commented 6 years ago

I put up an official build for Edge: https://github.com/NanoAdblocker/NanoCore/releases I'm sure there are many bugs left...

jspenguin2017 commented 6 years ago

document.querySelectorAll doesn't return an iterable object? wat? This should fix the broken element picker. image

jspenguin2017 commented 6 years ago

Hold on... The syntax highlighting is more broken on Edge than I expected... image

jspenguin2017 commented 6 years ago

Old opening:

![image](https://user-images.githubusercontent.com/7283682/34023516-95b0dabc-e102-11e7-802e-c82ce2784234.png) It looks like the cosmetic engine is 95% broken, some errors in the background page too. Looks like it's more complicate than I thought. But hey, it does start... Icons are broken, might need a separate manifest.
jspenguin2017 commented 6 years ago

I see the problem with cloud UI, it's not a problem with Edge, it's @gorhill 's programming error. There is no documentation saying that messaging is always slower than XHR. It's not a safe assumption on any browser, it just happens that XHR is way faster on both Chrome and Firefox. https://github.com/NanoAdblocker/NanoCore/commit/413f04105867e542bd1dfba83ddbb6b1ddf60392

The comment in nikrolls's code is misleading, it's not Edge "syncs in the background", which sounds like Edge will "write to storage.sync in the background after telling the extension it's done", it's Edge has a faster messaging pump, in fact, it looks like the callback is sometimes synchronous (which uncovered a(nother) race condition bug in Nano Linter).

jspenguin2017 commented 6 years ago

@reunicorn I reserved the name (cost me $20, but it's one-time fee unlike cough Apple cough), I have Appx package built although Microsoft won't accept it until they have reviewed the Chrome version, eh, wat?

Firefox developer account is free, Google developer account is a one-time fee of $5 for Chrome extensions and (another) $20 for Android app, Microsoft developer account is a one-time fee of $20, Apple developer account is $99 per year.

reunicorn commented 6 years ago

That's great news! Thank you especially for your work (and kevin12314's) in working around Edge's current shortcomings. Yes, it's bizarre how Microsoft is managing their extension ecosystem. Hopefully things will get better after Redstone 4 is released this March/April. Sorry that you've had to pay those fees. That Apple fee is astronomical! Am I correct that you don't accept donations? If not, do you have a favorite charity that I could give to as a sign of thanks?

jspenguin2017 commented 6 years ago

I can't accept donation as none of the contributors of uBO accepts that. The guy doing Safari port of uBO have to pay $99 per year, and he isn't asking for donation.

It's a one-time fee and honestly I probably have to get the Microsoft developer license one day anyway. It was a good learning experience, I now know how to use clever breakpoints to get around Edge's horrible debugger.

I checked uBO-Edge repository, their shim is incomplete, cloud UI and reload fixes are hacked together, but well, whatever works... There are 2 other crashes that are not addressed, which is why Edge version of uBO is kind of wonky:

Opening background console doesn't let you see previous errors, you need to run location.reload() to get them. Clicking the reload extension button closes the debugger...

I can PR but I'm not sure when nikrolls will be back... If he's back then it's like 10 lines of code to copy and he probably doesn't need a PR.

Nano will also instruct Edge to show the icon on the address bar automatically, and that was the last problem to address. Can't think of anything else that's broken for now. As always, bug reports welcomed.

jspenguin2017 commented 6 years ago

Edge isn't missing too many APIs, privacy and a better webRequest is all we need. Also the tab reload function is a nice-to-have.

reunicorn commented 6 years ago

I noticed on your "Installation on Edge" page that you have/require version 40.15063.674.0 of Edge. The latest stable version of Edge is actually 41.16299.15.0, available in the Fall Creators Update. I think it has some added APIs and features, and I know that it has better developer tools than version 40. If you haven't updated to Windows 10 Fall Creators Update (1709) it might not be a bad idea :)

jspenguin2017 commented 6 years ago

Eh what? Both of my Windows devices are still on 15063... Am I missing something? image

reunicorn commented 6 years ago

Yes, you're missing the latest update. You can go here to Microsoft's download page and click Update Now to install version 16299.

jspenguin2017 commented 6 years ago

Oh, interesting, since the Edge version won't hit Microsoft Store for a while, I might try it out. It would eventually be pushed through regular Windows Update, right?

kevin12314 commented 6 years ago

Microsoft push "Featuer Update" to Windows Update is always slowly, but yes, it would eventually be pushed through regular Windows Update.

reunicorn commented 6 years ago

Yes, that's right, eventually it would be pushed to your system. They always do a staggered release of new major Windows versions. 16299 has been out for just over 3 months now.

Here are the new developer features in Edge 41 (they especially focused on DevTools improvements), and Here are all the new Edge user features.

jspenguin2017 commented 6 years ago

My wishlist:

kevin12314 commented 6 years ago

@jspenguin2017 When I clicked on Nano defender icon in Edge, it did nothing. I checked F12 and it showed SCRIPT5007: Object expected. In 1-background-core.js row 112. Edge still not support runtime.openOptionsPage() API. I did this change to workaround.

chrome.browserAction.onClicked.addListener(() => {
        if(a.isEdge){
            var optionsUrl = chrome.extension.getURL("options.html");
           chrome.tabs.create({ url: optionsUrl })
       }
       else{
           chrome.runtime.openOptionsPage();
       }        
    });
jspenguin2017 commented 6 years ago

I'm aware of this and it's on my (private) to-do list. It's not a serious problem so there is no rush, I'll fix it sometime next week.

jspenguin2017 commented 6 years ago

The problems with options page on Edge are now fixed.

bash550 commented 6 years ago

Not sure if this appropriate or not, but thanks for this extension. I've been waiting for ages to get something this good on Edge. Even with the dev version the bandwidth savings are great. I came across it here. Sorry for posting this here. Keep up the great work.

jspenguin2017 commented 6 years ago

OK, I got Edge 41, and document.querySelectorAll is behaving properly now. The current shim for that function is extremely expensive, maybe I should drop the support for Edge 40. For some unknown reason, Microsoft doesn't disclose the proper Edge version in navigator.userAgent.

new Date().toLocaleString("fullwide") still throws on Edge.

jspenguin2017 commented 6 years ago

Edge now supports these request types, need to test if fetch can be (ab)used to bypass XHR filtering.

[main_frame,sub_frame,stylesheet,script,image,object,xmlhttprequest,fetch,ping,other]

In comparison, Chrome's accepted types are:

"main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest",
"ping", "csp_report", "media", "websocket", or "other"
jspenguin2017 commented 6 years ago

After a quick test, fetch is causing problems:

lewisje commented 6 years ago

I believe that what was done under the old nsIContentPolicy in Firefox was using xmlhttprequest filters to match both xmlhttprequest and fetch; there was an internal list of filter types that he request types were mapped to, and it was modified as the set of request types changed (in particular, including Web fonts and HTML5 media).

jspenguin2017 commented 6 years ago

The current system isn't scalable, I'll patch Edge's API instead, and make them work nicely with a Chrome extension. https://github.com/jspenguin2017/Edgyfy

jspenguin2017 commented 6 years ago

I rolled out a hotfix for Edge: https://github.com/NanoAdblocker/NanoCore/commit/de3425c6cb5643542a45a1441fe44b1911d34043 Hopefully I didn't blow other things up...

jspenguin2017 commented 6 years ago

A small update on my test devices, my Surface Pro 4 is having some problems, it blue screens every 10 minutes when I'm at home and once or twice when I'm at school. I tried everything and it looks like I have to try Ubuntu to see if it works better as Microsoft tech support is the biggest meme in modern history. The recovery option are mostly decoy buttons, the only one that actually works is reinstall from cloud which pulls an equally broken copy of Windows.

I will still have one Windows device left, but it's running an unregistered copy of Windows which means I'll ditch it if Microsoft ever decides to force unregistered users to pay. Edge support might be dropped if I ever delete the last copy of Windows.

I guess I can always run a VM but honestly I don't want to.

kevin12314 commented 6 years ago

Using Windows sometimes requires a completely fresh installation is already a normal one. Just remember to backup important files. There still a lot of tools make Windows registered. You can go to My Digital Life Forum to find them. I still hope you can continue to support Microsoft Edge.

jspenguin2017 commented 6 years ago

@kevin12314 I tried that, Microsoft won't let me to do a fresh install. The button doesn't work. I switched to Ubuntu and it stopped crashing since then, although something is glitchy about sleep and hibernate.

kevin12314 commented 6 years ago

Maybe you can go to https://www.microsoft.com/en-us/software-download/windows10. Download Media Creation Tool and create USB install media. Reboot computer and boot into USB install media to install windows 10. If installer need install key, just click skip button. after finish install and connect to internet, your pc will auto registered

jspenguin2017 commented 6 years ago

@kevin12314 That's exactly what I did, doesn't work.