-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: how do I subscribe to [these rules](https://github.com/tumpio/requestcontrol/tree/master/rules)?? #152
Comments
IDK from where you got the impression that there is a subscribe function in RC, but AFAIK there is no such feature. Actually a subscribe function is a bad idea IMHO because it of the power of RC-rules. Unlike uB for example where a bad list could either block everything or allow everything, a bad RC rule can redirect you to a faked login page for example.
You can down load the repository:
Click on the "Raw" button, then you can Ctrl+S the file.
Open a new tab, open the console (https://developer.mozilla.org/en-US/docs/Tools/Web_Console#opening_the_web_console), allow pasting (and understand why it is not allowed by default) and paste the following ( fetch("https://api.github.com/repos/tumpio/requestcontrol/contents/rules")
.then(function (response) {return response.json()})
.then(function (data) {return data.map(function (elem) {return elem.name})})
.then(function (rules) {return rules.map(function (rule) {return fetch("https://raw.githubusercontent.com/tumpio/requestcontrol/master/rules/" + rule).then(function (data) {return data.json()})})})
.then(function (rules) {return Promise.all(rules).then(function (rules) {console.log(JSON.stringify(rules.flat()))})}) Then you can copy the result and save it to a file. edit: Improved version: fetch("https://api.github.com/repos/tumpio/requestcontrol/contents/rules").then(resp => resp.json())
.then(files => files.map(file => file.name))
.then(filenames => filenames.map(filename => fetch("https://raw.githubusercontent.com/tumpio/requestcontrol/master/rules/" + filename).then(resp => resp.json())))
.then(rules => Promise.all(rules).then(rules => document.getElementsByTagName("html")[0].innerText = JSON.stringify(rules.flat()))) And improved a second time: fetch("https://api.github.com/repos/tumpio/requestcontrol/contents/rules")
.then(resp => resp.json())
.then(files => files.map(file => file.name))
.then(filenames => {
return filenames.map(filename => {
return fetch(
"https://raw.githubusercontent.com/tumpio/requestcontrol/master/rules/" + filename
).then(resp => resp.json())
})
})
.then(rules => Promise.all(rules).then(rules => {
document.getElementsByTagName("html")[0].innerHTML = `
<body>
<h1>
All RequestControl Rules
</h1>
<p>
Copy the text below, put it in a json file (e.g. RequestControl-Rules.json) and
import it in RequestControl.
</p>
<code></code>
</body>
`;
document.getElementsByTagName("code")[0].innerText = JSON.stringify(rules.flat());
})); |
There is no subscribe feature. You can only import rules from a local file. Github also allows to download a single file using the "Raw" link button. Support for manually importing rules listed in the rules folder or from a custom source could be added. |
Let me see if I understand this correctly (I'm really new to this and may have misunderstood): @rusty-snake's solution requires me to use a keyboard shortcut …I suppose I could try to create a new file and simply paste the content of the rules there? If so, what format should the file be on and what app should I use to create it? Maybe a |
My solution does not work in Firefox for Android, however you can do it iin a Desktop Firefox, Chrome, Edge, Vivaldi, Safari, Opera, Epiphany, ... and then copy the result to your phone (e.g. via g-drive). Instead of
All rules in one file requires you to slightly edit the rules. (That what my code does)
It's a JSON file
You can use every app that can create plain text files ( |
I'll try that when I have a computer available, which might not be any time soon.
That didn't work, I don't see any "save" option other than "save as PDF" when inside the "raw" file, and long pressing the "raw" button doesn't provide any options other than "open link in new tab", "open link in private tab", etc.
Do you mind explaining your answer to me again, then, please? Try to imagine you're talking to a child kkkkkkkkk I understand that when I get a computer I need to go to the "raw" file (?), press
Er… I don't have any app in mind, I was thinking maybe if I opened a context menu on the background of GDrive and pressed "new" maybe there would be a |
The difference between the solutions is that @tumpio solution give you 14 files that you need to import while my script merges them into one "file". About the usage of my script, you don't need to run it on a raw page. It doesn't matter where you run it as long as there is no SOP/CORS/CSP/WHATEVER that disallows the fetch of one of the resource. And the two later versions override the content of the page. |
Oooh! Very cool! Thank you! Both for the code and for the clarification! |
Hi! Sorry! I'm new here and I have no idea what I'm doing. I know this is a dumb question, but how do I subscribe to these rules? There is no "subscribe" button, and on the extension there's only an "import from file" button (not from the internet), yet, on the folder, there's no "download" button to download all files to storage at once so I can then import them into the extension afterwards, and trying to manually open each file shows no individual "download" button that I can see either. How do I subscribe to these rules and/or import these rules to my extension?
The text was updated successfully, but these errors were encountered: