How to block a code in specific file in developer tools? - google-chrome-devtools

When loading the index.html page in the index file there is javascript code. How can I block this particular code when the page index.html is loading?
the code that I want to block is
<script>
(function () {
setTimeout(function(){
dataLayer.push({
'a': '13'
});
}, 100);
})();
</script>

Using developer tools(three-dot menu > More Tools > Developer Tools), you can delete lines in the website for the ongoing session. This would effectively prevent the script from running. If you want to see all the scripts on the sites you visit, use the Firefox browser coupled with the NoScript add-on. This will show you all the scripts on the site, and allow you to give various permissions to each of them. If you own the index.html file and have it on your local computer, then simply comment out or delete the script that you don't want.

Related

Links with target=_blank opens in browser

In my PWA website, I have in a few places, links that open in new tab using target="_blank". I want to maintain this functionality but not if the user has installed the PWA.
Currently, if the user installs the PWA and click on that link, the user is taken to the browser and the page loads there.
I have tried all different kinds of scope but all give same result.
/
./
https://beta.domain.com/
// Add this script after </body>
<script>
if (window.matchMedia('(display-mode: standalone)').matches) {
// if webapp installed, remove 'target' attribute of links
document.querySelectorAll('a[target=_blank]').forEach(function(a) {
a.removeAttribute('target');
});
}
</script>

Squarespace code injecting

I injected <script> tags into my squarespace template making the <main> display:none. Now I cannot edit that section through squarespace because it is gone. Recommendations how to get it back without starting from scratch?
$( "#page" ).css( "display", "none" );
was the code I injected into the HTML.
Thank you in advance.
Its hard to understand what you are asking, but i'll assume that you added that single line of code, it hides everything when you navigate to your site page, and you are not sure how to go back to the adminstration page to remove that line of code?
You used "code injection" to insert that code. You can go back to that same code injection location and remove that line of code. The squarespace manual has documentation on code injection. If you are not sure where to go to get back to the administration pages, you can enter a url like this: https://<yoursite>/config for example: https://mysquarespacesite.com/config
For your problem I have one solution using Chrome inspector console tool(inbuilt tool of Chrome browser), make sure you open your website on Chrome browser with login to your squarespace website and follow these steps:
On your website homepage for example: https://<yoursite>/config, Click F12 from your keyboard OR right click using mouse and click on Inspect which will show you inspector mode of Chrome browser
Go to Console tab from inspector tool
Paste following code into Console:
document.getElementById('page').style.display = "block";
Hit enter and your <main> tag will be set as display block
Now your <main> section should be visible, go to code injection of your website and permanently remove display : none which will fix your website hiding <main> section problem for forever
Following are pictures of every step:
Note: I have tested this code into demo template of Squarespace website: https://bedford-demo.squarespace.com
Use the below code. Your code will execute only when you are not logged in as administrator.
if (window.top.location.href == window.self.location.href) {
$("#page").css("display", "none");
}

How to run Auto Hot Key file from web Page?

Is there any way to call or run .ahk files from web page using any of (HTML - JS - PHP)?
I need to start ahk files from my web pages on link or button clicks
Here is an example of how it can be done by using some evil activeX.
It used to be possible to access a users whole computer using activeX in the Internet Explorer. Nowadays ActiveX is mostly disabled. But we can still create .hta files to render html etc and these files allow the usage of activeX.
Try to save this as something.hta
<!DOCTYPE html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=9'>
<script language="JScript">window.resizeTo(200,100);</script>
<script language="JScript">
function runAhkScript() {
var ahkExePath = "C:/Program Files/AutoHotkey/AutoHotkey.exe";
var scriptToExecute = "C:/aaa/a.ahk";
new ActiveXObject("Shell.Application").ShellExecute(ahkExePath, scriptToExecute)
}
</script>
</head>
<body>
Run the autohotkey script
</body>
Adjust the path to your autohotkey.exe and your script and make sure you use forward slashes in the pathes.
You can not do that while accessing your web pages over a remote server (even localhost). If you access your web page on your local machine (i.e., typing "file:///C:/path/my web page.html" in the browser), and you use Internet Explorer as your browser, you might try:
<button onclick="window.open('file:///C:/path/my ahk script.ahk')">
Launch My AHK Script
</button>
Or, you may have to try it this way:
<button onclick="Process.Start('C:\path\my ahk script.ahk')">
Launch My AHK Script
</button>
(But maybe switch the slashes to "/" or add "file:\\" (trying with two or three slashes, and in each direction).
Hth,

How do I restrict one-off page access in a Confluence page

In Confluence, for just one page I would like to restrict access, to just me and my associate, (until the page is ready)
Is there any way to do this from within the page, or do I need to apply formal "Page Restrictions" which requires admin access :(
If you have the {html} macro you could remove the edit command for everyone except you using javascript.
{hide-from:user=myname}
{html}
<script type="text/javascript">
AJS.$(document).ready(function() {
AJS.$("#editPageLink").hide();
});
</script>
{html}
{hide-from}
This will not prevent someone editing the page if they know how to get the page id and construct a url but it will prevent casual users from editing the page.

Addthis ads a hashtag and id to URL - how to remove it

In our CMS the developer added an "addthis.com" script which appends a hashtag and a tracking id to the browser address bar URL, for example http://www.site.com/about/#.UX6e2j7mK30
There is a solution how to get rid of this tracking but we are limited with CMS which only allows us to add javascripts to page header. The addthis script executes within page body and I need somehow to run the fix script after the default script has run. When I add the below script then the fix doesn't work. Is there any solution? Many thanks
<script type="text/javascript">
$(document).ready(function() {
var addthis_config = addthis_config||{};
addthis_config.data_track_addressbar = false;
});
</script>
Remove the $(document).ready and just declare addthis_config. Since this is just defining the configuration values for AddThis, there's no need to wait for the document to fully load. Because you're waiting for the document to load and then setting addthis_config, the AddThis code has already run and appended the addressbar tracking hash.